Terrain rendering method and device, electronic equipment and storage medium

By drawing terrain on the target canvas and generating a target terrain mask that aligns with the sub-model, the problem of differentiated terrain effects in modular game scenes is solved, simplifying the rendering process and reducing maintenance costs.

CN115920380BActive Publication Date: 2026-04-14NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-17
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In modular game scenes, it is difficult to achieve the same terrain effects as in overall modeled game scenes. Existing solutions have complex calculation logic, high maintenance costs, and large texture map sizes, making it impossible to balance modular modeling methods and terrain differentiation implementation methods.

Method used

By drawing terrain on the target canvas, obtaining spatial transformation parameters to generate an initial terrain mask, and performing spatial transformation to obtain the target terrain mask, the target terrain mask and the sub-model form different alignment relationships, and sampling and rendering are performed to achieve differentiated display of terrain effects.

Benefits of technology

Achieving the same terrain effects in modular game scenes as in the overall modeled game scene simplifies the rendering process, reduces the complexity of computational logic and maintenance costs, and reduces the size of texture maps.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115920380B_ABST
    Figure CN115920380B_ABST
Patent Text Reader

Abstract

The application provides a terrain rendering method and device, electronic equipment and computer readable storage medium. The method receives a terrain drawing operation through a target canvas, obtains at least one terrain in the target canvas according to the terrain drawing operation, then obtains terrain data of the target canvas, and obtains spatial transformation parameters between the target canvas and a target model. An initial terrain mask is generated according to the terrain data and the spatial transformation parameters. Then, the initial terrain mask is spatially transformed according to the spatial transformation parameters to obtain a target terrain mask. The target terrain mask and at least two sub-models in the target model form different alignment relationships. Finally, the target terrain mask is sampled to obtain sampling data, and each sub-model is rendered based on the sampling data and the different alignment relationships. The application decouples terrain drawing from a modular target model, and realizes differentiated display of terrain in the modular model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a terrain rendering method, apparatus, electronic device, and storage medium. Background Technology

[0002] In game engines, overall game scene modeling largely relies on terrain systems. Terrain systems are created by subdividing vertices on a fixed planar surface. Terrain brushes can be directly used to draw on different areas of the planar surface, displaying different terrain textures in a relatively simple and quick way. However, overall modeling of game scenes has a long production cycle, and when new sections need to be added, they must be recreated, resulting in zero reusability.

[0003] Due to the aforementioned shortcomings, many games adopt modular game scenes, where multiple sub-models are developed separately and then combined to form a single model. These sub-models can be reused, added, or flexibly replaced. However, since the dividing lines between adjacent sub-models often do not coincide with the mesh dividing lines in the planar patches, directly using terrain brushes in modular game scenes will result in abnormal terrain at the boundaries between adjacent sub-models. Furthermore, using terrain brushes on multiple reused sub-models will only produce the same terrain effect, failing to achieve differentiated display. Therefore, current modular game scenes cannot directly use terrain brushes to achieve the same terrain effect as the overall modeled game scene. To solve this problem, the current solution is to design different texture maps for different sub-models, design the desired terrain effect in each texture map, and then use separate texture mapping to display different terrain textures for different sub-models. However, this approach requires consideration of the connection issues between different texture maps, making the related calculation logic complex and maintenance costly. Furthermore, when the number of sub-models in the game scene is large, the number of texture maps that need to be designed is also large, and each texture map accounts for a significant portion of the game package size, making the entire production process quite complex.

[0004] Therefore, the current game scene suffers from a technical problem where it is difficult to balance modular modeling and terrain differentiation, and needs to be improved. Summary of the Invention

[0005] This application provides a terrain rendering method, apparatus, electronic device, and storage medium to alleviate the technical problem that it is difficult to simultaneously achieve modular modeling and terrain differentiation in existing game scenes.

[0006] To address the aforementioned technical problems, this application provides the following technical solutions:

[0007] This application provides a terrain rendering method applied to a target model, the target model comprising at least two sub-models, the terrain rendering method comprising:

[0008] Receive terrain drawing operations through a target canvas, and obtain at least one type of terrain in the target canvas based on the terrain drawing operations;

[0009] Obtain the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model; generate an initial terrain mask based on the terrain data and the spatial transformation parameters.

[0010] The initial terrain mask is spatially transformed according to the spatial transformation parameters to obtain the target terrain mask, and the target terrain mask forms different alignment relationships with the at least two sub-models.

[0011] The target terrain mask is sampled to obtain sampled data, and each sub-model is rendered based on the sampled data and the different alignment relationships.

[0012] Meanwhile, this application also provides a terrain rendering device applied to a target model, the target model including at least two sub-models, the terrain rendering device including:

[0013] The module is configured to receive a terrain drawing operation through a target canvas, and obtain at least one type of terrain in the target canvas based on the terrain drawing operation.

[0014] The generation module is used to acquire the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model, and generate an initial terrain mask based on the terrain data and the spatial transformation parameters.

[0015] A spatial transformation module is used to perform spatial transformation on the initial terrain mask according to the spatial transformation parameters to obtain a target terrain mask, wherein the target terrain mask forms different alignment relationships with the at least two sub-models;

[0016] The rendering module is used to sample the target terrain mask to obtain sampled data, and to render each sub-model based on the sampled data and the different alignment relationships.

[0017] This application also provides an electronic device, including a memory and a processor; the memory stores an application program, and the processor is used to run the application program in the memory to perform the operations in any of the above-described terrain rendering methods.

[0018] This application provides a computer-readable storage medium storing multiple instructions adapted for loading by a processor to execute the steps in the terrain rendering method described above.

[0019] This application provides a terrain rendering method, apparatus, electronic device, and computer-readable storage medium. The method first receives a terrain drawing operation through a target canvas, obtains at least one type of terrain in the target canvas according to the terrain drawing operation, then acquires the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model, generates an initial terrain mask according to the terrain data and the spatial transformation parameters, then performs a spatial transformation on the initial terrain mask according to the spatial transformation parameters to obtain a target terrain mask, the target terrain mask forms different alignment relationships with at least two sub-models, and finally samples the target terrain mask to obtain sampled data, and renders each sub-model separately based on the sampled data and the different alignment relationships. This application first draws the desired terrain effect on the target canvas and saves the terrain data. Then, it generates a target terrain mask aligned with the target model. The target terrain mask and each sub-model in the target model form different alignment relationships. Subsequently, the target terrain mask can be sampled, and based on the sampled data and the different alignment relationships, each sub-model can be rendered differently. This allows the terrain effect of different parts of the target terrain mask to be displayed in each sub-model, and finally, the complete terrain effect designed in the target terrain mask is displayed in the target model. The presentation of this terrain effect is only related to the target terrain mask and not to the target model. The number, combination, and reuse of each sub-model are irrelevant. Even two identical reused sub-models can present different terrain effects based on the different alignment relationships mentioned above. That is, the solution of this application decouples terrain rendering from the target model, and can achieve the same terrain effect as the overall modeling game scene in the modular game scene. It achieves a balance between modular modeling and terrain differentiation. Moreover, the rendering process only requires an aligned mask, and there is no need to consider the texture connection between each sub-model. The relevant logic of the whole process is relatively simple, the maintenance cost is low, and the mask volume ratio is also small. Attached Figure Description

[0020] The technical solution and other beneficial effects of this application will become apparent from the following detailed description of specific embodiments in conjunction with the accompanying drawings.

[0021] Figure 1 This is a schematic diagram illustrating an application scenario of the terrain rendering method provided in the embodiments of this application.

[0022] Figure 2 This is a schematic diagram of the target model before terrain rendering in the embodiments of this application.

[0023] Figure 3 This is a schematic diagram of the target model after terrain rendering in an embodiment of this application.

[0024] Figure 4 A schematic diagram of a planar patch in a comprehensive terrain modeling system.

[0025] Figure 5 To be directly in Figure 2 A schematic diagram of terrain rendering on the target model.

[0026] Figure 6 This is a schematic flowchart of the terrain rendering method provided in an embodiment of this application.

[0027] Figure 7 This is a schematic diagram of the target canvas in an embodiment of this application.

[0028] Figure 8 This is a schematic diagram illustrating the alignment relationship between the target terrain mask and each sub-model in an embodiment of this application.

[0029] Figure 9 This is a schematic diagram of the first sampling method when sampling a mask.

[0030] Figure 10 This is a schematic diagram of the second sampling method when sampling a mask.

[0031] Figure 11 This is a schematic diagram illustrating the segmentation of the target terrain mask in an embodiment of this application.

[0032] Figure 12 This is a schematic diagram of the boundary between two types of terrain in the prior art.

[0033] Figure 13 This is a schematic diagram of the boundary between two types of terrain in an embodiment of this application.

[0034] Figure 14 This is a logical diagram illustrating the overlay display of various terrain types in the embodiments of this application.

[0035] Figure 15 This is a schematic diagram of the terrain rendering device provided in an embodiment of this application.

[0036] Figure 16 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0037] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0038] This application provides a terrain rendering method, apparatus, electronic device, and computer-readable storage medium. The terrain rendering apparatus can be integrated into an electronic device, which can be a server or a terminal, etc.

[0039] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating a scenario in which the terrain rendering method provided in this application embodiment is applied. This application scenario includes a client, which is a device running a game engine. Wherein:

[0040] The art designers first generate a target canvas within the game engine's editor on the client side, and then perform terrain rendering operations on the target canvas, which yields at least one type of terrain. Next, the client acquires and records the terrain data for each terrain type, saving the completed target canvas as a rendering object to form an initial terrain mask. Simultaneously, the spatial transformation parameters between the target canvas and the target model are also saved. Then, the client performs a spatial transformation on the initial terrain mask according to the spatial transformation parameters to obtain the target terrain mask, aligning the target terrain mask with each sub-model within the target model. Finally, the target terrain mask is sampled, and based on the sampled data and the alignment relationships, each sub-model within the target model is rendered separately, achieving the terrain effect drawn on the target canvas within the target model, which contains at least two sub-models.

[0041] It should be noted that, Figure 1 The system scenario diagram shown is merely an example. The servers and scenarios described in this application embodiment are for the purpose of more clearly illustrating the technical solutions of this application embodiment and do not constitute a limitation on the technical solutions provided by this application embodiment. As those skilled in the art will know, with the evolution of systems and the emergence of new business scenarios, the technical solutions provided by this application embodiment are also applicable to similar technical problems. Detailed descriptions are provided below. It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of embodiments.

[0042] In this embodiment, modular technology refers to first establishing two or more game modules, and then combining these modules to form a complete game scene. When two or more game modules have the same design requirements, only one game module needs to be established, and this module can be reused when combining to form a complete game scene, thereby reducing development costs. Furthermore, when a small scene needs to be added to the current game scene, only the game module corresponding to the new scene needs to be developed, and then it can be combined with other modules in the current game scene, allowing the current game scene to be reused. Compared to the overall modeling approach, modular technology reduces the workload of modeling, allows each game module to be developed simultaneously, shortens the development cycle, and offers high reusability. Modifying, adding, or replacing scenes is relatively simple; therefore, many games use modular technology to build game scenes.

[0043] In this embodiment, the target model refers to the original map model in the game scene. The target model is formed by combining at least two sub-models, each of which is a part of the original map model. The sub-models are combined to form a complete map, which is then applied to the game scene. Each sub-model is built based on an independent terrain system, which is a system created by performing vertex subdivision and other operations on a fixed planar patch. Since the target model is the original map model, that is, a model without various terrain elements, various terrain elements such as beaches, grasslands, watercourses, and trees need to be added to the target model before it is applied to the game scene to meet the requirements of the game scene.

[0044] The overall shape of the target model, as well as the shape, number, and combination of each sub-model, vary depending on the specific game scenario. For ease of explanation, the following embodiments of this application will use the term "target model" to refer to the shape of the target model and the shape, number, and combination of each sub-model. Figure 2 Taking the target model shown in the image for terrain rendering as an example, as... Figure 2 The diagram shows the target model used as the original map model, which includes nine sub-models from A to I. Figure 3 The image shows a schematic diagram of the target model after terrain rendering, which includes both sandy and grassy terrain.

[0045] like Figure 4 As shown, for the overall terrain system modeled in the game engine, various terrain types are directly drawn on a planar surface using a terrain brush. This planar surface includes multiple grid lines, and the grid lines intersect to form multiple vertices. When the terrain brush brushes across the planar surface, the vertices and grids in the brushed area are rendered to form the corresponding terrain texture. By setting the relevant parameters of the terrain brush and controlling the drawing method, different terrain effects can be obtained in different areas. Therefore, the implementation of terrain is relatively simple and quick.

[0046] For modular terrain systems, on the one hand, when sub-models are merged into a single target model, the dividing lines between adjacent sub-models are usually not consistent with the grid lines of the aforementioned planar patches. This makes the development methods for the overall terrain system different from those for the modular terrain system. Terrain brushes that can be directly used in a complete terrain system cannot be directly used in a modular terrain system; otherwise, errors will occur at the dividing lines of the sub-models. On the other hand, two or more sub-models reused in the target model are identical sub-models. These sub-models have completely identical shapes, sizes, and other features. When terrain is directly painted on one of these sub-models using a painting tool, the other identical sub-models will also display the same terrain effect. However, the texture requirements for different areas in a game scene are usually different. Therefore, modular game scenes cannot directly achieve differentiated texture effects using terrain brushes. Specifically, for example... Figure 5 As shown, assuming sub-model A and sub-model E are reused sub-models, if grassland terrain is drawn directly on sub-model E, the same grassland terrain will also be displayed in sub-model A. This is obviously inconsistent with... Figure 3 The terrain effect that was intended to be presented does not match.

[0047] Therefore, it is evident that directly drawing terrain on the model is not feasible in current modular game scenarios. To solve this problem, the current method for terrain creation involves designing different mask maps for different sub-models, designing the desired terrain effect in each mask map, and then applying textures to each sub-model to achieve different terrain textures for different sub-models. For example, for Figure 2 The target model in the game contains nine sub-models, requiring nine texture maps. However, the connection between different mask maps needs to be considered. For example, the texture map of sub-model E needs to be connected with other mask maps in all four directions (up, down, left, and right). To ensure the terrain effect at the dividing lines between adjacent sub-models, each connection point requires related logical operations, making the calculation logic complex and the maintenance cost high. Furthermore, too many mask maps complicate the production process and significantly increase the game's file size. In addition, this method of drawing each mask separately makes the overall terrain less intuitive, requiring art designers to perform extensive import / export and modification work on each mask to ensure the overall terrain effect.

[0048] As the above demonstrates, achieving the same terrain effects in a modular game scene as in a fully modeled game scene is currently quite difficult; in other words, it's challenging to simultaneously achieve modular modeling and terrain differentiation. To address this technical problem, this application provides a novel terrain rendering method that uses a simpler and more intuitive approach to enable modular game scenes to achieve the same terrain effects as fully modeled game scenes.

[0049] In the embodiments of this application, please refer to Figure 6 , Figure 6 This is a flowchart illustrating the terrain rendering method provided in an embodiment of this application, specifically including:

[0050] S1: Receive terrain drawing operations through the target canvas, and obtain at least one type of terrain in the target canvas based on the terrain drawing operations.

[0051] The terrain rendering method in this application is primarily implemented within the game engine. First, a target canvas is created in the game engine's editor. Then, art designers perform terrain drawing operations on this target canvas, using tools such as terrain brushes. The editor typically offers several default terrain brushes, each corresponding to a different terrain texture. By selecting a terrain brush and then clicking or dragging it on the target canvas, the corresponding terrain, such as beaches, grasslands, streams, mountains, and any other type of terrain, can be drawn within the dragged area. If the default terrain brushes in the editor do not meet the design requirements, a new terrain brush can be created, and its corresponding terrain texture can be selected. Terrain textures are customizable, and brush attributes such as intensity, size, and shape can also be adjusted.

[0052] like Figure 7 As shown, different types of terrain can be obtained by performing terrain drawing operations on the target canvas. For ease of explanation, this embodiment and the following embodiments use beach terrain and grassland terrain drawn on the target canvas as examples. When drawing, the entire beach terrain is drawn first, and then grassland terrain is drawn on a part of the beach terrain, that is, the grassland terrain covers this part of the beach terrain. However, it should be noted that this application is not limited to this. Other terrains can also be drawn on the target canvas. Art designers can flexibly select, create and set all relevant drawing tools provided by the game engine, and perform different terrain drawing operations to intuitively design any complete terrain effect that they want to achieve in the game scene on the target canvas.

[0053] S2: Obtain the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model. Generate an initial terrain mask based on the terrain data and spatial transformation parameters.

[0054] Each terrain element drawn on the target canvas has corresponding terrain data, including material information, texture information, and region information. The target canvas is drawn in UV space in the editor, while the target model in subsequent steps is in world space. To achieve the transformation of the target canvas from UV space to world space, designers need to set spatial transformation parameters between the target canvas and the target model based on the size and current position of the target canvas. These parameters include translation, scaling, and rotation parameters. In other words, spatial transformation parameters characterize the translation, rotation, and scaling operations required for the target canvas to be transformed from UV space to world space and aligned with the target model.

[0055] The target canvas containing the terrain needs to be converted into a render target (RT) in the game engine before it can be used for subsequent sampling and rendering. This render target forms an initial terrain mask. The render target is a cached texture drawn by a computer program. The program obtains the terrain data of each terrain from the target canvas obtained in the previous step, and then draws the initial terrain mask based on this terrain data, while also storing the set spatial transformation parameters.

[0056] In one embodiment, S2 specifically includes: obtaining the correspondence between each preset channel of the target canvas and each terrain; and obtaining terrain data of each terrain from each preset channel according to the correspondence. The target canvas has multiple preset channels, such as RGBA channels. Each preset channel can be used to store terrain data of one or more types of terrain. The type of terrain data stored in each preset channel can be predefined, such as the R channel storing beach terrain data, the G channel storing grassland terrain data, etc., forming a correspondence between each preset channel and each terrain. When drawing on the target brush, the terrain data generated for each terrain will be stored in the corresponding preset channel. When the program needs to generate an initial terrain mask, it can obtain this correspondence and obtain the terrain data of each terrain from each preset channel according to the correspondence, and then draw them separately. After obtaining the initial terrain mask, the mask also has these preset channels, and the terrain data of each terrain in the initial terrain mask will also be stored in the corresponding preset channels based on this correspondence.

[0057] S3: Perform spatial transformation on the initial terrain mask according to the spatial transformation parameters to obtain the target terrain mask, and the target terrain mask forms different alignment relationships with at least two sub-models.

[0058] Based on the spatial transformation parameters carried by the initial terrain mask, a spatial transformation is performed on the initial terrain mask in the shader to convert it from UV space to world space, thus obtaining the target terrain mask. The transformation between the two satisfies the following formula:

[0059] f(WorldPosition)=(Texturecoord.uv-offset)*Scale*M Rotation (Formula 1)

[0060] Where Texturecoord.uv is the coordinates of each point in the initial terrain mask in UV space, f(WorldPosition) is the coordinates of the corresponding point in the target terrain mask in world space, offset is the translation value of the initial terrain mask from the UV coordinate system to the world coordinate system, Scale is the scaling factor of the initial terrain mask from the UV coordinate system to the world coordinate system. Since the target canvas does not have a height axis, the height axis is fixed at 1, M Rotation It is the rotation transformation matrix of the initial terrain mask from the UV coordinate system to the world coordinate system.

[0061] After spatial transformation, both the target terrain mask and the target model reside in the same space, and the target terrain mask forms different alignment relationships with each sub-model within the target model. Different alignment relationships mean that, assuming the target model comprises n sub-models, and the target terrain mask is divided into n masking regions, then the masking region i of the target terrain mask completely overlaps with the terrain rendering surface of sub-model i, or the masking region i of the target terrain mask is projected along a direction perpendicular to the terrain rendering surface of sub-model i and completely overlaps with sub-model i. In other words, the target terrain mask forms n different alignment relationships with sub-models 1 to n, and the terrain effect in masking region i is consistent with the desired terrain effect in sub-model i.

[0062] Specifically, such as Figure 8 As shown, the target model includes nine sub-models, A to I. After spatial transformation, the target terrain mask can be divided into nine masking regions, 1 to 9. Masking region 1 is aligned with sub-model A in shape, size, and position, forming the first alignment relationship. Masking region 2 is aligned with sub-model B in shape, size, and position, forming the second alignment relationship. And so on. Each other masking region is aligned with a unique and different sub-model, forming a total of nine different alignment relationships.

[0063] In one embodiment, before S3, the method further includes: obtaining the image information entropy of the initial terrain mask; determining the partitioning parameters of the initial terrain mask based on the image information entropy and the densest arrangement algorithm; and partitioning the initial terrain mask according to the partitioning parameters to obtain at least two masking blocks.

[0064] A target terrain mask contains all the terrain that needs to be drawn in the entire target model. However, in the actual game scene, the area that players focus on is only a part of it. To ensure the player's gaming experience, the terrain production requirements for these areas will be higher. For some non-focused areas, although terrain production is also required, since players usually do not pay much attention to these areas, the production accuracy requirements for these areas can be appropriately reduced.

[0065] The terrain rendering accuracy of different regions on the target model is positively correlated with the sampling accuracy of different regions in the mask. When the sampling accuracy is high, the terrain rendering accuracy of the corresponding region on the target model is also high, and the terrain presentation effect is also better. Currently, there are two main sampling methods for mask images: one is overall uniform sampling, and the other is sampling key and non-key areas separately. However, both methods have certain drawbacks.

[0066] like Figure 9 As shown, this is a uniform sampling scheme. The large rectangle in the image represents the sampling range. If the entire target terrain mask is uniformly sampled using the area enclosed by the rectangle, most of the sampled data will be too uniform. Specifically, using higher sampling precision can meet the terrain creation requirements of key areas, but since the terrain creation requirements of non-key areas do not need to be so high, using higher sampling precision will waste computational resources in non-key areas. Conversely, if the sampling precision is reduced to avoid wasting computational resources in non-key areas, the sampling precision of key areas will be insufficient, resulting in poor terrain effects in subsequent creations and affecting the player's gaming experience.

[0067] like Figure 10 The diagram shows a sampling scheme for key areas of interest. This scheme needs to be coordinated with... Figure 9 The two schemes are combined, that is, first according to Figure 9 The middle scheme performs a uniform sampling at the required sampling precision for non-key areas of concern, and then follows... Figure 10 The middle scheme samples only the key areas of interest with the required sampling precision. Then, the two schemes are combined and the sampling data of the key areas of interest in the uniform sampling scheme are removed, thereby achieving different sampling precisions for different areas. Figure 10 Each small rectangle represents a sampling range. Since the areas that players focus on in the game scene are not completely equal, and the sampling range needs to be a regular shape, these sampling ranges will overlap to a certain extent in order to ensure that the sampling data covers all the areas of focus. This will cause the sampling points in the overlapping areas to be sampled twice or more, which will also waste computing resources.

[0068] In this embodiment, the image information entropy of the initial terrain mask is used as the standard, and the sampling area is divided by combining the densest arrangement algorithm to obtain two or more mask blocks. Each mask block corresponds to a sampling area. These mask blocks do not overlap, and the key interest areas and non-key interest areas can be accurately divided.

[0069] Specifically, the image information entropy of the initial terrain mask is first obtained. Image information entropy reflects the richness of terrain rendering details in each region of the initial terrain mask. When a region has more terrain rendering details, its information entropy will be larger, and vice versa. Typically, when art designers render the terrain, to ensure the player experience, areas with rich terrain rendering details will cover the areas that players focus on. In other words, the information entropy of the areas that players focus on is usually larger, while the information entropy of the areas that players do not focus on is relatively smaller. Therefore, the information entropy distribution of each region in the entire initial terrain mask is not equal. After obtaining the image information entropy of the initial terrain mask, we can roughly determine which regions are the areas of focus and which are the areas of non-focus. Then, these regions are further divided to obtain two or more sampling regions. Each sampling region forms a mask block, thereby compressing the information in a large and complete initial terrain mask into multiple smaller mask blocks, making the original terrain effect in the initial terrain mask more detailed and precise.

[0070] To avoid Figure 10 To address the overlap of regions while ensuring that all information in the initial mask is captured, a densest arrangement algorithm is needed to determine the partitioning parameters. These parameters include the position and size of each sampling region, as well as the total number of sampling regions. Since the sampling regions need to be rectangular, the densest arrangement algorithm can also be called the rectangular arrangement algorithm. This involves finding the globally optimal arrangement of multiple smaller rectangles of unequal size within a given large rectangle, maximizing the utilization of the large rectangular area while ensuring that the smaller rectangles do not overlap. In this embodiment, these smaller rectangles are each sampling region.

[0071] When dividing the sampling area, the information entropy of different locations in the initial terrain mask can be calculated and sorted. If the information entropy of a certain area is large, a smaller sampling area is selected for that area; if the information entropy of a certain area is large, a larger sampling area is selected. At the same time, the densest arrangement algorithm is combined to calculate the most reasonable sampling area division method, so that all the sampling areas obtained in the end do not overlap, while covering all the terrain, and the terrain patterns with large information entropy and the terrain patterns with small information entropy are located in different sampling areas.

[0072] In the above process, the formula for calculating the block information entropy of each masked block is as follows:

[0073]

[0074] Where p(x) i y j ) represents the color of each point in the masked area, N(y) j Let E(X, Y) be a normal distribution function, and E(X, Y) be the information entropy of the entire masking block. If a masking block contains more terrain details, the terrain pattern will contain more colors, and the calculated block information entropy will be higher. Conversely, if a masking block contains fewer terrain details, the terrain pattern will contain fewer colors, and the calculated block information entropy will be lower. Therefore, this application calculates and sorts the block information entropy, and then combines it with the densest arrangement algorithm to accurately divide the key and non-key areas in the initial terrain masking, obtaining the most reasonable partitioning parameters. Finally, based on these partitioning parameters, the initial terrain masking can be divided into multiple masking blocks, such as... Figure 11 As shown, different sampling precisions can be set for different masked blocks to ensure both efficient use of computing resources and a good player experience.

[0075] It should be noted that, Figure 11 The masking block division results shown are only illustrative; the actual division needs to be calculated. Alternatively, masking blocks can be divided manually. It should also be noted that the masking block division is based on block information entropy, while the masking region division mentioned in the above embodiments is based on the different alignment relationships between the target terrain mask and each sub-model. These two methods are independent and do not affect each other. Therefore, a masking block can cover only one masking region, or it can cover two or more masking regions; it can cover a complete masking region, or it can cover only a part of a masking region. Based on this, a sub-model can correspond to only one sampling precision, or it can correspond to two or more different sampling precisions.

[0076] S4: Sample the target terrain mask to obtain sampled data, and render each sub-model based on the sampled data and different alignment relationships.

[0077] The terrain data on the target terrain mask is sampled using a sampler to obtain sampled data. This sampled data includes the current color of each point in the target terrain mask. Then, based on different alignment relationships, the corresponding points on different sub-models are colored separately, i.e., terrain rendering is performed. This allows each sub-model to present the terrain effect within its corresponding masked area, ensuring that the target model ultimately presents the complete terrain effect originally designed by the art designers. In this way, the same terrain effect as the overall modeled game scene is achieved in a modular game scene.

[0078] In one embodiment, S4 specifically includes: determining the mapping point corresponding to each sampling point in the target terrain mask in each sub-model based on the different alignment relationships between the target terrain mask and each sub-model; and rendering each mapping point based on the sampling data of each sampling point. Since each masking area in the target terrain mask is aligned with each sub-model, each sampling point in each masking area of ​​the target terrain mask can find a corresponding mapping point in the aligned sub-model. Therefore, after determining the sampling points, the position of each mapping point in each sub-model is first determined according to the different alignment relationships. After sampling the target terrain mask to obtain the color of each sampling point, the mapping point is colored with the color of each sampling point so that the mapping point displays the same color as the sampling point. After coloring all mapping points, the terrain effect in each sub-model can be made the same as the terrain effect in the aligned masking area, ultimately making the terrain effect in the target model the same as that in the target terrain mask.

[0079] In one embodiment, before S4, the method further includes: obtaining the area of ​​each masking block; and determining the sampling precision of each masking block based on its area. In the previous step, multiple masking blocks were obtained. The areas of these blocks are not entirely equal, varying in size. Larger masking blocks correspond to areas of less interest, while smaller blocks correspond to areas of greater interest. Therefore, the sampling precision of each masking block can be determined based on its area. Larger masking blocks have lower sampling precision, while smaller blocks have higher sampling precision. Then, in this step, a shading precision matching the sampling precision is used to render the area corresponding to each masking block in the target model. This ensures that the terrain detail in areas of greater interest to the player is maintained while avoiding wasting resources in areas of less interest.

[0080] In one embodiment, S4 specifically includes: obtaining the correspondence between each preset channel of the target terrain mask and each terrain; obtaining terrain data of each terrain from each preset channel according to the correspondence; obtaining the position information of each sampling point in the target terrain mask; and obtaining the sampling data of each sampling point according to the position information of each sampling point and the terrain data of each terrain.

[0081] The target terrain mask is derived from the initial terrain mask. During the conversion process, the preset channels remain consistent. After conversion, each preset channel stores the terrain data of various landforms within the target terrain mask. First, the correspondence between each preset channel and each landform is obtained. Then, based on this correspondence, the terrain data of each landform is extracted from each preset channel, such as extracting beach terrain data from the R channel and grassland terrain data from the G channel. Next, the location information of each sampling point in the target terrain mask is determined based on the required sampling accuracy. Since each type of terrain data includes regional information of each landform, it is combined with the location information of a specific sampling point. Then, the color at that location is collected from each type of terrain data, ultimately forming the sampling data for that sampling point. In other words, the sampling data for each sampling point contains color data collected from all preset channels.

[0082] In one embodiment, the step of obtaining sampling data for each sampling point based on the location information of each sampling point and the terrain data of each terrain includes: obtaining the actual terrain height of each terrain at the target sampling point based on the location information of the target sampling point and the terrain data of each terrain; determining the highest target actual terrain height from each actual terrain height, and determining the terrain corresponding to the target actual terrain height as the target terrain; and obtaining the target sampling data of the target sampling point based on the target terrain data of the target terrain.

[0083] Since the target terrain mask may contain multiple terrains, some of which may exist alone and others may overlap, for the case where a single terrain exists, such as a sampling point that only includes beach terrain, only the R channel in the four RGBA channels can capture a valid color. The color sampled in the R channel can be used to color the mapped point on the target model to present a single beach color. However, if a sampling point contains both beach terrain and grass terrain, both the R and G channels in the four RGBA channels can capture valid colors. When coloring, the two need to be mixed.

[0084] Currently, the color values ​​from the two channels are mixed linearly, meaning both colors contribute to the final displayed color. This mixing method causes an error in the reflectivity of the mixed area, resulting in a color that doesn't match either of the two colors. For example... Figure 12 As shown, the dark area is grass, the light area is sand, and the boxed area is the mixed area. In a real scene, the mixed area should also be partly sand and partly grass, with a clear boundary between the two. However, using linear blending will result in a terrain state in the mixed area that is neither sand nor grass, and the boundary between the two terrains will become blurred, resulting in a poor terrain effect.

[0085] In this embodiment, the color of the terrain to be displayed at each sampling point is determined by comparing the actual terrain height at each sampling point. This color is unique, meaning that each point will receive only a unique color when coloring the target model, and there will be no mixing of two colors. Figure 13 The effect shown clearly shows the boundaries between different terrains, allowing art designers to use terrain brushes to depict more precise content.

[0086] In one embodiment, the step of obtaining the terrain height of each terrain at the target sampling point based on the location information of the target sampling point and the terrain data of each terrain includes: obtaining the initial terrain height of each terrain; obtaining the offset terrain height of each terrain at the target sampling point based on the location information of the target sampling point and the terrain data of each terrain; and obtaining the actual terrain height of each terrain at the target sampling point based on the initial terrain height and the offset terrain height.

[0087] The specific logic described above is as follows: Figure 14 As shown, heightMap1 to heightMap4 are the initial values ​​set in the editor for the height of the terrain to be stored in the four RGBA channels, i.e., the initial terrain height. For example, if the initial terrain height of the grass terrain is H, then when drawing with this type of terrain brush, the height of all drawn grass terrain will be H, and the entire grass will appear as a plane. mask.r, mask.g, mask.b, and mask.a are the terrain data corresponding to the four RGBA channels of the target terrain mask. The location of the terrain in the current channel can be recorded as 1, and the location of the terrain can be recorded as 0. For each sampling point, the initial terrain height heightMap2 of the grass terrain in its G channel is multiplied by the terrain data mask.g (1 or 0) of that point to obtain the terrain height h2 of the grass terrain at that sampling point. If there is grass terrain at that sampling point, then h2 is equal to H; if there is no grass terrain at that sampling point, then h2 is equal to 0. The calculation process is similar for the terrain in other channels. h1 to h4 represent the terrain height of the current sampling point in the four RGBA channels, respectively.

[0088] a1 to a4 represent the offset height values ​​of each sampling point in the four channels. In actual game scenarios, each terrain is usually not a flat plane but needs to present an uneven effect. Therefore, an offset terrain height needs to be set based on the tangent direction, normal direction, and slope of each sampling point. This can include positive and negative values. When it is positive, it means that the point needs to be higher than the initial terrain height; when it is negative, it means that the point needs to be lower than the initial terrain height. The actual terrain height of the sampling point is obtained by superimposing the terrain height value of the sampling point in each channel with the offset height value, which is h1+a1, h2+a2, h3+a3, and h4+a4 in the figure. Then, the maximum value among the four is calculated. This maximum value is the target actual terrain height, and the terrain corresponding to the maximum value is the target terrain.

[0089] The actual terrain height of the target is subtracted by a reference height (Height) greater than 0 to obtain its offset value *ma* relative to the reference height. Then, this offset value *ma* is subtracted from *h1+a1*, *h2+a2*, *h3+a3*, and *h4+a4* respectively, and the results are compared with 0. The larger value between the two is output. Now, assuming *h1+a1* is the maximum value, then *ma* is *h1+a1* - *Height*. *h1+a1* - *ma* equals *Height*, which is greater than 0, so *b1* is *Height*. Since *h2+a2*, *h2+a2*, *h3+a3*, and *h4+a4* are all less than *h1+a1*, *h2+a2* - *ma*, *h3+a3* - *ma*, and *h4+a4* - *ma* are all less than 0, therefore *b2*, *b3*, and *b4* are all 0. Finally, since only *b1* is 0, corresponding to the R channel, the terrain to be displayed at this sampling point is ultimately a beach. That is, the above calculation logic is used to determine the unique terrain to be displayed at each sampling point, in order to obtain... Figure 13 The clear boundaries are shown in the figure.

[0090] As can be seen from the above embodiments, the terrain rendering method of this application first draws the required terrain effect on the target canvas and saves the terrain data. Then, it generates a target terrain mask aligned with the target model. The target terrain mask and each sub-model in the target model form different alignment relationships. Subsequently, the target terrain mask can be sampled, and based on the sampled data and the different alignment relationships, each sub-model can be rendered differently. This allows the terrain effect of different parts of the target terrain mask to be displayed in each sub-model, and finally, the complete terrain effect designed in the target terrain mask is displayed in the target model. The presentation of this terrain effect is only related to the target model. The shape mask is related to the number, combination, and reuse of each sub-model in the target model. Even two identical reused sub-models can present different terrain effects based on the different alignment relationships mentioned above. That is, the solution of this application decouples terrain rendering from the target model, and can achieve the same terrain effect as the overall modeled game scene in the modular game scene. It achieves a balance between high reusability and terrain differentiation. Moreover, the rendering process only requires one aligned mask, and there is no need to consider the texture connection between each sub-model. The relevant logic of the whole process is relatively simple, the maintenance cost is low, and the size of the mask is also small.

[0091] Accordingly, such as Figure 15 As shown, this application also provides a terrain rendering apparatus, specifically including:

[0092] The module 10 is configured to receive a terrain drawing operation through a target canvas and, based on the terrain drawing operation, obtain at least one type of terrain in the target canvas.

[0093] The generation module 20 is used to acquire the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model, and generate an initial terrain mask based on the terrain data and the spatial transformation parameters.

[0094] The spatial transformation module 30 is used to perform spatial transformation on the initial terrain mask according to the spatial transformation parameters to obtain a target terrain mask, wherein the target terrain mask forms different alignment relationships with the at least two sub-models.

[0095] The rendering module 40 is used to sample the target terrain mask to obtain sampled data, and to render each sub-model based on the sampled data and the different alignment relationships.

[0096] In one embodiment, the terrain rendering apparatus further includes:

[0097] The first acquisition module is used to acquire the image information entropy of the initial terrain mask;

[0098] The determination module is used to determine the partitioning parameters of the initial terrain mask based on the image information entropy and the densest arrangement algorithm;

[0099] The partitioning module is used to partition the initial terrain mask according to the partitioning parameters to obtain at least two masking blocks.

[0100] In one embodiment, the terrain rendering apparatus further includes:

[0101] The second acquisition module is used to acquire the area of ​​each masking block;

[0102] The second determining module is used to determine the sampling accuracy of each masking block based on the size of each block area.

[0103] In one embodiment, the rendering module 40 includes:

[0104] The first acquisition submodule is used to acquire the correspondence between each preset channel of the target terrain mask and each terrain.

[0105] The second acquisition submodule is used to acquire terrain data of each terrain from each preset channel according to the correspondence.

[0106] The third acquisition submodule is used to acquire the location information of each sampling point in the target terrain mask;

[0107] The submodule is used to obtain sampling data for each sampling point based on the location information of each sampling point and the terrain data of each region.

[0108] In one embodiment, obtaining the submodule includes:

[0109] The first obtaining unit is used to obtain the actual terrain height of each terrain at the target sampling point based on the location information of the target sampling point and the terrain data of each terrain.

[0110] The determining unit is used to determine the highest target actual terrain height from each actual terrain height, and to determine the terrain corresponding to the target actual terrain height as the target terrain.

[0111] The second obtaining unit is used to obtain target sampling data of the target sampling point based on the terrain data of the target terrain.

[0112] In one embodiment, the first obtaining unit is used to:

[0113] Obtain the initial terrain elevation for each terrain type;

[0114] Based on the location information of the target sampling point and the terrain data of each terrain, the offset terrain height at the target sampling point is obtained;

[0115] Based on the initial terrain height and the offset terrain height, the actual terrain height of each terrain at the target sampling point is obtained.

[0116] In one embodiment, the rendering module 40 includes:

[0117] The determination submodule is used to determine the mapping points corresponding to each sampling point in the target terrain mask in each sub-model based on the different alignment relationships between the target terrain mask and each sub-model;

[0118] The rendering submodule is used to render each mapping point based on the sampled data of each sampling point.

[0119] The terrain rendering apparatus of this application first draws the desired terrain effect on the target canvas and saves the terrain data. Then, it generates a target terrain mask aligned with the target model. The target terrain mask and each sub-model in the target model form different alignment relationships. Subsequently, the target terrain mask can be sampled, and based on the sampled data and the different alignment relationships, each sub-model can be rendered differently. This allows the terrain effect of different parts of the target terrain mask to be displayed in each sub-model, and finally, the complete terrain effect designed in the target terrain mask is displayed in the target model. The presentation of this terrain effect is only related to the target terrain mask. Regardless of the number, combination, or reuse of each sub-model in the target model, even two identical reused sub-models can present different terrain effects based on the different alignment relationships mentioned above. That is, the solution of this application decouples terrain rendering from the target model, and can achieve the same terrain effect as the overall modeled game scene in the modular game scene. It achieves a balance between high reusability and terrain differentiation, and the rendering process only requires one aligned mask. There is no need to consider the texture connection between each sub-model. The relevant logic of the whole process is relatively simple, the maintenance cost is low, and the mask volume ratio is also small.

[0120] Accordingly, embodiments of this application also provide an electronic device, such as... Figure 16 As shown, the electronic device may include a radio frequency (RF) circuit 101, a memory 102 including one or more computer-readable storage media, an input unit 103, a display unit 104, a sensor 105, an audio circuit 106, a WiFi module 107, a processor 108 including one or more processing cores, and a power supply 109, among other components. Those skilled in the art will understand that... Figure 16 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0121] The radio frequency circuit 101 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and hands it over to one or more processors 108 for processing; additionally, it transmits uplink data to the base station. The memory 102 can be used to store software programs and modules. The processor 108 executes various functional applications and data processing by running the software programs and modules stored in the memory 102. The input unit 103 can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.

[0122] The display unit 104 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the server. These graphical user interfaces can be composed of graphics, text, icons, videos, and any combination thereof.

[0123] The electronic device may also include at least one sensor 105, such as a light sensor, a motion sensor, and other sensors. Audio circuitry 106 includes a speaker that provides an audio interface between the user and the electronic device.

[0124] WiFi is a short-range wireless transmission technology. Electronic devices using the WiFi module 107 can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 16 WiFi module 107 is shown, but it is understood that it is not a necessary component of the electronic device and can be omitted as needed without changing the nature of the application.

[0125] The processor 108 is the control center of the electronic device. It connects various parts of the phone through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 102, and calling data stored in the memory 102, it performs various functions of the electronic device and processes data, thereby monitoring the phone as a whole.

[0126] The electronic device also includes a power supply 109 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 108 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system.

[0127] Although not shown, electronic devices may also include cameras, Bluetooth modules, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 108 in the server loads the executable files corresponding to the processes of one or more applications into the memory 102 according to the following instructions, and the processor 108 runs the applications stored in the memory 102. The application is applied to the target model, which includes at least two sub-models, thereby achieving the following functions:

[0128] Receive terrain drawing operations through a target canvas, and obtain at least one type of terrain in the target canvas based on the terrain drawing operations;

[0129] Obtain the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model; generate an initial terrain mask based on the terrain data and the spatial transformation parameters.

[0130] The initial terrain mask is spatially transformed according to the spatial transformation parameters to obtain the target terrain mask, and the target terrain mask forms different alignment relationships with the at least two sub-models.

[0131] The target terrain mask is sampled to obtain sampled data, and each sub-model is rendered based on the sampled data and the different alignment relationships.

[0132] In one embodiment, the following functionality is achieved:

[0133] Obtain the image information entropy of the initial terrain mask;

[0134] Based on the image information entropy and the densest arrangement algorithm, the partitioning parameters of the initial terrain mask are determined;

[0135] The initial terrain mask is divided into at least two masking blocks according to the partitioning parameters.

[0136] In one embodiment, the following functionality is achieved:

[0137] Obtain the area of ​​each masked region;

[0138] The sampling accuracy of each masking block is determined based on the size of each block area.

[0139] In one embodiment, the following functionality is achieved:

[0140] Obtain the correspondence between each preset channel of the target terrain mask and each terrain feature;

[0141] Based on the aforementioned correspondence, terrain data for each terrain type is obtained from each preset channel;

[0142] Obtain the location information of each sampling point in the target terrain mask;

[0143] Based on the location information of each sampling point and the topographic data of each region, the sampling data of each sampling point is obtained.

[0144] In one embodiment, the following functionality is achieved:

[0145] Based on the location information of the target sampling point and the terrain data of each terrain, the actual terrain height of each terrain at the target sampling point is obtained;

[0146] Determine the highest target actual terrain height from all actual terrain heights, and define the terrain corresponding to the target actual terrain height as the target terrain.

[0147] Based on the target terrain data, the target sampling data of the target sampling point is obtained.

[0148] In one embodiment, the following functionality is achieved:

[0149] Obtain the initial terrain elevation for each terrain type;

[0150] Based on the location information of the target sampling point and the terrain data of each terrain, the offset terrain height at the target sampling point is obtained;

[0151] Based on the initial terrain height and the offset terrain height, the actual terrain height of each terrain at the target sampling point is obtained.

[0152] In one embodiment, the following functionality is achieved:

[0153] Based on the different alignment relationships between the target terrain mask and each sub-model, determine the mapping points corresponding to each sampling point in the target terrain mask in each sub-model;

[0154] Each mapping point is rendered based on the sampling data of each sampling point.

[0155] The electronic device of this application first draws the desired terrain effect on the target canvas and saves the terrain data. Then, it generates a target terrain mask aligned with the target model. The target terrain mask and each sub-model in the target model form different alignment relationships. Subsequently, the target terrain mask can be sampled, and based on the sampled data and the different alignment relationships, each sub-model can be rendered differently. This allows different parts of the terrain effect in the target terrain mask to be displayed in each sub-model, and finally, the complete terrain effect designed in the target terrain mask is displayed in the target model. The presentation of this terrain effect is only related to the target terrain mask. Regardless of the number, combination, or reuse of each sub-model in the target model, even two identical reused sub-models can present different terrain effects based on the different alignment relationships mentioned above. That is, the solution in this application decouples terrain rendering from the target model, and can achieve the same terrain effect as the overall modeled game scene in the modular game scene. It achieves a balance between high reusability and terrain differentiation, and the rendering process only requires one aligned mask. There is no need to consider the texture connection between each sub-model. The relevant logic of the whole process is relatively simple, the maintenance cost is low, and the mask size is also small.

[0156] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed description above, and they will not be repeated here.

[0157] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0158] Therefore, embodiments of this application provide a computer-readable storage medium storing multiple instructions that can be loaded by a processor. These instructions are applied to a target model, which includes at least two sub-models, to achieve the following functions:

[0159] Receive terrain drawing operations through a target canvas, and obtain at least one type of terrain in the target canvas based on the terrain drawing operations;

[0160] Obtain the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model; generate an initial terrain mask based on the terrain data and the spatial transformation parameters.

[0161] The initial terrain mask is spatially transformed according to the spatial transformation parameters to obtain the target terrain mask, and the target terrain mask forms different alignment relationships with the at least two sub-models.

[0162] The target terrain mask is sampled to obtain sampled data, and each sub-model is rendered based on the sampled data and the different alignment relationships.

[0163] In one embodiment, the following functionality is achieved:

[0164] Obtain the image information entropy of the initial terrain mask;

[0165] Based on the image information entropy and the densest arrangement algorithm, the partitioning parameters of the initial terrain mask are determined;

[0166] The initial terrain mask is divided into at least two masking blocks according to the partitioning parameters.

[0167] In one embodiment, the following functionality is achieved:

[0168] Obtain the area of ​​each masked region;

[0169] The sampling accuracy of each masking block is determined based on the size of each block area.

[0170] In one embodiment, the following functionality is achieved:

[0171] Obtain the correspondence between each preset channel of the target terrain mask and each terrain feature;

[0172] Based on the aforementioned correspondence, terrain data for each terrain type is obtained from each preset channel;

[0173] Obtain the location information of each sampling point in the target terrain mask;

[0174] Based on the location information of each sampling point and the topographic data of each region, the sampling data of each sampling point is obtained.

[0175] In one embodiment, the following functionality is achieved:

[0176] Based on the location information of the target sampling point and the terrain data of each terrain, the actual terrain height of each terrain at the target sampling point is obtained;

[0177] Determine the highest target actual terrain height from all actual terrain heights, and define the terrain corresponding to the target actual terrain height as the target terrain.

[0178] Based on the target terrain data, the target sampling data of the target sampling point is obtained.

[0179] In one embodiment, the following functionality is achieved:

[0180] Obtain the initial terrain elevation for each terrain type;

[0181] Based on the location information of the target sampling point and the terrain data of each terrain, the offset terrain height at the target sampling point is obtained;

[0182] Based on the initial terrain height and the offset terrain height, the actual terrain height of each terrain at the target sampling point is obtained.

[0183] In one embodiment, the following functionality is achieved:

[0184] Based on the different alignment relationships between the target terrain mask and each sub-model, determine the mapping points corresponding to each sampling point in the target terrain mask in each sub-model;

[0185] Each mapping point is rendered based on the sampling data of each sampling point.

[0186] The computer-readable storage medium of this application first draws the desired terrain effect on the target canvas and saves the terrain data. Then, it generates a target terrain mask aligned with the target model. The target terrain mask and each sub-model in the target model form different alignment relationships. Subsequently, the target terrain mask can be sampled, and based on the sampled data and the different alignment relationships, each sub-model can be rendered differently. This allows different parts of the terrain effect in the target terrain mask to be displayed in each sub-model, and finally, the complete terrain effect designed in the target terrain mask is displayed in the target model. The presentation of this terrain effect is only related to the target terrain mask. The terrain effect is independent of the number, combination, and reuse of each sub-model in the target model. Even two identical reused sub-models can present different terrain effects based on the different alignment relationships mentioned above. That is, the solution of this application decouples terrain rendering from the target model, and can achieve the same terrain effect as the overall modeled game scene in the modular game scene. It achieves a balance between high reusability and terrain differentiation. Moreover, the rendering process only requires an aligned mask, and there is no need to consider the texture connection between each sub-model. The relevant logic of the whole process is relatively simple, the maintenance cost is low, and the mask volume is also small.

[0187] The above provides a detailed description of a terrain rendering method, apparatus, electronic device, and computer-readable storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of this application. Those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A terrain rendering method, characterized in that, Applied to a target model, the target model comprising at least two sub-models, the terrain rendering method includes: Receive terrain drawing operations through a target canvas, and obtain at least one type of terrain in the target canvas based on the terrain drawing operations; Obtain the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model; generate an initial terrain mask based on the terrain data and the spatial transformation parameters. The initial terrain mask is spatially transformed according to the spatial transformation parameters to obtain the target terrain mask, and the target terrain mask forms different alignment relationships with the at least two sub-models. The target terrain mask is sampled to obtain sampled data, and each sub-model is rendered based on the sampled data and the different alignment relationships. The step of spatially transforming the initial terrain mask according to the spatial transformation parameters to obtain the target terrain mask includes: Based on the spatial transformation parameters carried by the initial terrain mask, the initial terrain mask is spatially transformed from UV space to world space to obtain the target terrain mask. The transformation between the two satisfies the following formula: in, Texturecoord.uv These are the coordinates of each point in the initial terrain mask in UV space. These are the coordinates of the corresponding points in the target terrain mask in world space. `offset` is the translation value of the initial terrain mask from the UV coordinate system to the world coordinate system. `Scale` is the scaling factor of the initial terrain mask from the UV coordinate system to the world coordinate system. M Rotation It is the rotation transformation matrix of the initial terrain mask from the UV coordinate system to the world coordinate system; The different alignment relationships refer to the fact that the n masking regions obtained by dividing the target terrain masking form n different alignment relationships with the n sub-models 1 to n in the target model. Among them, the masking region i of the target terrain masking completely coincides with the terrain creation surface of the sub-model i, or the masking region i of the target terrain masking is projected along a direction perpendicular to the terrain creation surface of the sub-model i and completely coincides with the sub-model i.

2. The terrain rendering method as described in claim 1, characterized in that, Before the step of spatially transforming the initial terrain mask according to the spatial transformation parameters, the method further includes: Obtain the image information entropy of the initial terrain mask; Based on the image information entropy and the densest arrangement algorithm, the partitioning parameters of the initial terrain mask are determined; The initial terrain mask is divided into at least two masking blocks according to the partitioning parameters.

3. The terrain rendering method as described in claim 2, characterized in that, Prior to the step of sampling the target terrain mask, the method further includes: Obtain the area of ​​each masked region; The sampling accuracy of each masking block is determined based on the size of each block area.

4. The terrain rendering method as described in claim 1, characterized in that, The step of sampling the target terrain mask to obtain sampling data includes: Obtain the correspondence between each preset channel of the target terrain mask and each terrain feature; Based on the aforementioned correspondence, terrain data for each terrain type is obtained from each preset channel; Obtain the location information of each sampling point in the target terrain mask; Based on the location information of each sampling point and the topographic data of each region, the sampling data of each sampling point is obtained.

5. The terrain rendering method as described in claim 4, characterized in that, The steps for obtaining sampling data for each sampling point based on its location information and topographic data of each region include: Based on the location information of the target sampling point and the terrain data of each terrain, the actual terrain height of each terrain at the target sampling point is obtained; Determine the highest target actual terrain height from all actual terrain heights, and define the terrain corresponding to the target actual terrain height as the target terrain. Based on the target terrain data, the target sampling data of the target sampling point is obtained.

6. The terrain rendering method as described in claim 5, characterized in that, The step of obtaining the terrain elevation of each terrain at the target sampling point based on the location information of the target sampling point and the terrain data of each terrain includes: Obtain the initial terrain elevation for each terrain type; Based on the location information of the target sampling point and the terrain data of each terrain, the offset terrain height at the target sampling point is obtained; Based on the initial terrain height and the offset terrain height, the actual terrain height of each terrain at the target sampling point is obtained.

7. The terrain rendering method as described in claim 1, characterized in that, The steps of rendering each sub-model based on the sampled data and the different alignment relationships include: Based on the different alignment relationships between the target terrain mask and each sub-model, determine the mapping points corresponding to each sampling point in the target terrain mask in each sub-model; Each mapping point is rendered based on the sampling data of each sampling point.

8. A terrain rendering device, characterized in that, Applied to a target model, the target model comprising at least two sub-models, the terrain rendering apparatus includes: The module is configured to receive a terrain drawing operation through a target canvas, and obtain at least one type of terrain in the target canvas based on the terrain drawing operation. The generation module is used to acquire the terrain data of the target canvas and the spatial transformation parameters between the target canvas and the target model, and generate an initial terrain mask based on the terrain data and the spatial transformation parameters. A spatial transformation module is used to perform spatial transformation on the initial terrain mask according to the spatial transformation parameters to obtain a target terrain mask, wherein the target terrain mask forms different alignment relationships with the at least two sub-models; The rendering module is used to sample the target terrain mask to obtain sampled data, and render each sub-model based on the sampled data and the different alignment relationships. The step of spatially transforming the initial terrain mask according to the spatial transformation parameters to obtain the target terrain mask includes: Based on the spatial transformation parameters carried by the initial terrain mask, the initial terrain mask is spatially transformed from UV space to world space to obtain the target terrain mask. The transformation between the two satisfies the following formula: in, Texturecoord.uv These are the coordinates of each point in the initial terrain mask in UV space. These are the coordinates of the corresponding points in the target terrain mask in world space. `offset` is the translation value of the initial terrain mask from the UV coordinate system to the world coordinate system. `Scale` is the scaling factor of the initial terrain mask from the UV coordinate system to the world coordinate system. M Rotation It is the rotation transformation matrix of the initial terrain mask from the UV coordinate system to the world coordinate system; The different alignment relationships refer to the fact that the n masking regions obtained by dividing the target terrain masking form n different alignment relationships with the n sub-models 1 to n in the target model. Among them, the masking region i of the target terrain masking completely coincides with the terrain creation surface of the sub-model i, or the masking region i of the target terrain masking is projected along a direction perpendicular to the terrain creation surface of the sub-model i and completely coincides with the sub-model i.

9. An electronic device, characterized in that, It includes a memory and a processor; the memory stores an application program, and the processor is used to run the application program within the memory to perform the steps in the terrain rendering method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is executed by a processor to implement the steps of the terrain rendering method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Model training and instance segmentation method, device and system and storage medium

    CN108875732A

  • Terrain splicing method and device, storage medium and electronic equipment

    CN115222594A