Game scene rendering method and device, equipment and storage medium
By constructing a terrain mask for the basic terrain layer and performing material mixing, the problems of large resource consumption and high hardware performance in existing technologies are solved, enabling efficient rendering of large-scale game terrain scenes on mobile devices.
Patent Information
- Application Number
- CN202111484543.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2026-05-15
- Estimated Expiration
- 2041-12-07
AI Technical Summary
Existing game scene rendering methods require a large amount of resources, resulting in high hardware performance requirements and making it difficult to achieve efficient rendering of large game terrain scenes on mobile devices.
By acquiring terrain data to construct a terrain mask for the basic terrain layer, and then performing material mixing based on the mask, the traditional block construction is replaced, achieving unified construction of blocks of the same type, reducing hardware performance requirements and resource consumption.
It enables the unified construction of blocks of the same type in game terrain scenes, reduces hardware performance requirements, improves the efficiency of game scene production, and makes large game terrain scenes suitable for mobile devices.
Smart Images

Figure CN116236778B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of game technology, and in particular to a game scene rendering method, apparatus, device, and storage medium. Background Technology
[0002] With advancements in hardware performance and industry technology, investment in the development of open-world or large-scale games is continuously increasing. These games attract many players with their large maps, high degree of freedom, and high-precision assets. A key technical aspect of developing these games is terrain creation. Existing large-scale games require the creation of complex terrain features based on block-based models, and various automated methods for map scene creation currently exist.
[0003] In existing map scene rendering methods, masks for the corresponding blocks of terrain are first created by establishing terrain distribution rules, such as cliffs and rocks in a game scene. These masks are then imported into the game engine for material import, thus obtaining the corresponding game scene. However, this game map rendering method creates the scene terrain on a block-by-block basis, which means that the required number of material layers, terrain distribution information, textures, and other resources are large, resulting in high hardware performance requirements. Summary of the Invention
[0004] The main objective of this invention is to solve the technical problem that existing game scene rendering methods require a large amount of resources, resulting in high hardware performance requirements.
[0005] The first aspect of the present invention provides a game scene rendering method, comprising: acquiring terrain data of a scene to be rendered; constructing a terrain mask corresponding to a terrain base layer simulating the terrain distribution in the scene to be rendered based on the terrain data; and performing material mixing on the terrain base layer based on the terrain mask to obtain the corresponding terrain scene.
[0006] Optionally, in a first implementation of the first aspect of the present invention, the method of performing material mixing on the terrain base layer based on the terrain mask to obtain the corresponding terrain scene includes: determining the border area between the terrain base layers based on the terrain mask, and calculating the mixing value between the pixel normal and vertex normal in the terrain base layer according to the border area; performing spatial angle offset on the terrain base layer according to the mixing value, and performing material mixing on the corresponding border area after the spatial angle offset to obtain the corresponding terrain scene.
[0007] Optionally, in the second implementation of the first aspect of the present invention, after constructing the terrain mask corresponding to the terrain base layer simulating the terrain distribution in the scene to be rendered based on the terrain data, the method further includes: determining the edge information of each terrain mask, and sequentially treating each terrain mask as a negative area; and sequentially adding edge noise to each terrain mask based on the negative area to obtain a new terrain mask.
[0008] Optionally, in the third implementation of the first aspect of the present invention, constructing a terrain mask corresponding to the terrain base layer simulating terrain distribution in the scene to be rendered based on terrain data includes: selecting a preset terrain distribution rule corresponding to the terrain base layer in the scene to be rendered based on terrain data, wherein the terrain base layer includes at least one or more of a first base layer, a second base layer, a third base layer, and a fourth base layer; and performing decomposition calculation and environmental simulation calculation on the corresponding terrain base layer in the scene to be rendered based on terrain data and using the selected terrain distribution rule to obtain the corresponding terrain mask.
[0009] Optionally, in the fourth implementation of the first aspect of the present invention, based on terrain data and using selected landform distribution rules, the corresponding landform base layer in the scene to be rendered is decomposed and calculated, and environmental simulation is performed to obtain the corresponding landform mask. This includes: if the landform base layer is a first base layer, then based on the terrain data, the flow field mask of the first landform base layer is calculated, and points are evenly scattered on the flow mask to obtain multiple original points; the tangent direction of each original point is calculated, and each original point is moved according to the tangent direction according to a preset speed to obtain simulated water flow distribution information; the original points in the simulated water flow part map are mapped to the height map corresponding to the terrain data to obtain the landform mask corresponding to the first base layer.
[0010] Optionally, in the fifth implementation of the first aspect of the present invention, the process of decomposing and calculating the corresponding terrain base layer in the scene to be rendered based on terrain data and using selected terrain distribution rules to obtain the corresponding terrain mask further includes: if the terrain base layer is a second base layer, then according to the terrain data and a preset first slope, performing gravity calculation and flow field calculation on the second base layer to obtain the geometric information corresponding to the second base layer; based on the geometric information corresponding to the second base layer, removing geometric regions smaller than a preset first area from the second base layer; distorting the geometric regions in the second base layer and returning the height map corresponding to the terrain data to obtain the corresponding terrain mask.
[0011] Optionally, in the sixth implementation of the first aspect of the present invention, the process of decomposing and calculating the corresponding landform base layer in the scene to be rendered based on terrain data and using selected landform distribution rules to obtain the corresponding landform mask further includes: if the landform base layer is a third base layer, then according to the terrain data and a preset second slope, performing flow field simulation calculation on the third base layer to obtain the regional data corresponding to the third base layer; and remapping the regional data corresponding to the third base layer to a preset numerical range to obtain the landform mask corresponding to the third base layer.
[0012] Optionally, in the seventh implementation of the first aspect of the present invention, the process of decomposing and calculating the corresponding terrain base layer in the scene to be rendered based on terrain data and using selected terrain distribution rules to obtain the corresponding terrain mask further includes: if the terrain base layer is the fourth base layer, then according to the terrain data, calculate the interval range corresponding to the fourth base layer according to a preset third slope and a preset height; calculate the occlusion mask corresponding to the interval range, and determine the occlusion area in the fourth base layer based on the occlusion mask; calculate the geometric information corresponding to the occlusion area, and remove geometric areas smaller than a preset second area from the fourth base layer based on the geometric information corresponding to the occlusion area; perform distortion calculation and fluid calculation on the geometric area in the fourth base layer, perform subtraction processing on the interval range and the calculated geometric area, and calculate the terrain mask corresponding to the fourth base layer based on the result of the subtraction processing.
[0013] Optionally, in the eighth implementation of the first aspect of the present invention, after calculating the landform mask corresponding to the fourth base layer based on the result of the difference processing, the method further includes: if the landform base layer also includes a fifth base layer, then performing simulated erosion processing on the landform mask corresponding to the third base layer; and remapping the landform mask after simulated erosion processing to obtain the landform mask corresponding to the fifth base layer.
[0014] Optionally, in the ninth implementation of the first aspect of the present invention, after remapping the landform mask after the simulated erosion treatment to obtain the landform mask corresponding to the fifth base layer, the method further includes: if the landform base layer also includes a sixth base layer, then the fifth base layer is extended to obtain the landform mask corresponding to the sixth base layer.
[0015] A second aspect of the present invention provides a game scene rendering apparatus, comprising: an acquisition module for acquiring terrain data of a scene to be rendered; a construction module for constructing a terrain mask corresponding to a terrain base layer simulating terrain distribution in the scene to be rendered based on the terrain data; and a material mixing module for performing material mixing on the terrain base layer based on the terrain mask to obtain a corresponding terrain scene.
[0016] Optionally, in a first implementation of the second aspect of the present invention, the material blending module includes: an offset unit, configured to determine the border area between the terrain base layers based on the terrain mask, and calculate the blending value between the pixel normal and the vertex normal in the terrain base layer according to the border area; and a material blending unit, configured to perform spatial angle offset on the terrain base layer according to the blending value, and perform material blending on the corresponding border area after the spatial angle offset to obtain the corresponding terrain scene.
[0017] Optionally, in a second implementation of the second aspect of the present invention, the game scene rendering device further includes an edge optimization module, used to: determine the edge information of each terrain mask, and sequentially treat each terrain mask as a negative region; according to the negative region, sequentially add edge noise to each terrain mask to obtain a new terrain mask.
[0018] Optionally, in a third implementation of the second aspect of the present invention, the construction module is further configured to: select a preset landform distribution rule corresponding to the landform base layer in the scene to be rendered based on the terrain data, wherein the landform base layer includes at least one or more of a first base layer, a second base layer, a third base layer, and a fourth base layer; and based on the terrain data, use the selected landform distribution rule to perform decomposition calculation and environmental simulation calculation on the corresponding landform base layer in the scene to be rendered to obtain the corresponding landform mask.
[0019] Optionally, in the fourth implementation of the second aspect of the present invention, the construction module includes a first construction unit, used for: if the landform base layer is a first base layer, then based on the terrain data, calculating the flow field mask of the first landform base layer, and uniformly scattering points on the flow mask to obtain multiple original points; calculating the tangent direction of each original point, and moving each original point according to the tangent direction according to a preset speed to obtain simulated water flow distribution information; mapping the original points in the simulated water flow partial map to the height map corresponding to the terrain data to obtain the landform mask corresponding to the first base layer.
[0020] Optionally, in the fifth implementation of the second aspect of the present invention, the construction module includes a second construction unit, configured to: if the landform base layer is a second base layer, perform gravity calculation and flow field calculation on the second base layer according to the terrain data and a preset first slope to obtain the geometric information corresponding to the second base layer; based on the geometric information corresponding to the second base layer, remove geometric regions smaller than a preset first area from the second base layer; perform distortion processing on the geometric regions in the second base layer and return the height map corresponding to the terrain data to obtain the corresponding landform mask.
[0021] Optionally, in the sixth implementation of the second aspect of the present invention, the construction module includes a third construction unit, used for: if the landform base layer is a third base layer, then according to the terrain data and according to the preset second slope, perform flow field simulation calculation on the third base layer to obtain the regional data corresponding to the third base layer; remap the regional data corresponding to the third base layer to a preset numerical range to obtain the landform mask corresponding to the third base layer.
[0022] Optionally, in the seventh implementation of the second aspect of the present invention, the construction module includes a fourth construction unit, used for: if the landform base layer is a fourth base layer, then calculating the interval range corresponding to the fourth base layer according to the terrain data, based on a preset third slope and a preset height; calculating the occlusion mask corresponding to the interval range, and determining the occlusion area in the fourth base layer based on the occlusion mask; calculating the geometric information corresponding to the occlusion area, and removing geometric areas smaller than a preset second area from the fourth base layer based on the geometric information corresponding to the occlusion area; performing distortion calculation and fluid calculation on the geometric area in the fourth base layer, performing subtraction processing on the interval range and the calculated geometric area, and calculating the landform mask corresponding to the fourth base layer based on the result of the subtraction processing.
[0023] Optionally, in the eighth implementation of the second aspect of the present invention, the fourth construction unit is further configured to: if the landform base layer further includes a fifth base layer, then perform simulated erosion processing on the landform mask corresponding to the third base layer; and remap the landform mask after simulated erosion processing to obtain the landform mask corresponding to the fifth base layer.
[0024] Optionally, in the ninth implementation of the second aspect of the present invention, the fourth building unit is further configured to: if the terrain base layer also includes a sixth base layer, extend the edge of the fifth base layer to obtain the terrain mask corresponding to the sixth base layer.
[0025] A third aspect of the present invention provides a game scene rendering device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor invokes the instructions in the memory to cause the game scene rendering device to execute the above-described game scene rendering method.
[0026] A fourth aspect of the present invention provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the above-described game scene rendering method.
[0027] The technical solution provided by this invention obtains the terrain data of the scene to be rendered; then, according to preset terrain distribution rules, it constructs the terrain mask corresponding to the terrain base layer in the scene to be rendered, so as to uniformly construct the terrain mask for each block in the scene to be rendered according to different types; finally, the corresponding terrain base layer can be mixed with materials according to the terrain mask to obtain the corresponding terrain scene. By using terrain distribution rules to replace block construction for terrain mask construction, it realizes the unified construction of blocks of the same type in the game terrain scene, thereby reducing the requirements for hardware performance and reducing the amount of resources required, thus improving the efficiency of game scene production, making large game terrain scenes suitable for mobile devices and easy to debug according to terrain distribution rules. Attached Figure Description
[0028] Figure 1 This is a schematic diagram of an embodiment of the game scene rendering method in this invention;
[0029] Figure 2 This is a schematic diagram of the basic terrain layers in the game scene in an embodiment of the present invention;
[0030] Figure 3 This is a schematic diagram simulating rainwater erosion in an embodiment of the present invention;
[0031] Figure 4 This is a schematic diagram of one embodiment of the game scene rendering device in this invention;
[0032] Figure 5 This is a schematic diagram of another embodiment of the game scene rendering device in this invention;
[0033] Figure 6 This is a schematic diagram of one embodiment of a game scene rendering device in this invention. Detailed Implementation
[0034] This invention provides a game scene rendering method, apparatus, device, and storage medium. The method involves acquiring terrain data of the scene to be rendered; constructing a terrain mask corresponding to a terrain base layer simulating the terrain distribution in the scene based on the terrain data; and performing material mixing on the terrain base layer based on the terrain mask to obtain the corresponding terrain scene. This invention achieves unified construction of blocks of the same type in game terrain scenes, reducing hardware performance requirements and resource consumption, improving game scene production efficiency, and making large game terrain scenes suitable for mobile devices and easy to adjust.
[0035] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” or “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0036] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1 The first embodiment of the game scene rendering method in this invention includes:
[0037] 101. Obtain the terrain data of the scene to be rendered;
[0038] It is understood that the executing entity of this invention can be a game scene rendering device, a terminal, or a server; no specific limitation is made here. This embodiment of the invention will be described using a server as an example.
[0039] In this embodiment, the scene to be rendered includes natural scenes such as mountains, plains, hills, and basins. Here, we will use mountains as an example to illustrate the scene to be rendered. For the terrain data of the mountains, we can use terrain data provided by the upstream art production team, which has a corresponding height map, including the relative height, absolute height, slope, and slope direction of the terrain structure presented in the scene to be rendered.
[0040] 102. Based on the terrain data, construct the terrain mask corresponding to the basic terrain layer simulating the terrain distribution in the scene to be rendered;
[0041] In this embodiment, based on prior knowledge, such as geological research and artistic requirements, the scene to be rendered, such as mountains, can be pre-divided into multiple geomorphic base layers according to the influence of natural environments such as climate dryness and humidity, and water erosion. For each geomorphic base layer, corresponding geomorphic distribution rules are pre-set to automatically generate geomorphic masks corresponding to each geomorphic base layer. These geomorphic distribution rules include, but are not limited to, the regional division of the geomorphic base layers and natural scene simulation. For example... Figure 2 As shown, the basic geomorphic layer can specifically include the following six items:
[0042] 1) Slope layer 201 represents the rocky slope region, which is mainly distributed on steep surfaces at high altitudes;
[0043] 2) Gravel layer 202 indicates the scree area, located at the lower part of the rocky slope where the slope is slightly steep;
[0044] 3) Flow layer 203 represents the eroded soil area, which is bare soil formed by rainwater erosion;
[0045] 4) Erosion layer 204 represents the sedimentary soil area, which is the sedimentation site on the low-altitude slope and the junction of grassland and other landform base layers.
[0046] 5) Debris layer 205 represents the dry soil area, which is a small depression where rainwater collects at low altitude;
[0047] 6) Grass layer 206 represents the grassland area, which can be other areas with gentler slopes.
[0048] This means that different types of terrain are constructed with corresponding terrain masks, without the need to construct each block individually. For blocks of the same terrain type, such as generating 5 gravel blocks in the scene to be constructed, the existing method constructs 5 gravel blocks separately, while by using terrain distribution rules, it is only necessary to define the area of the Gravel layer and then perform natural scene simulation to generate the required 5 gravel blocks.
[0049] The scene to be rendered may include one or more terrain base layers. When there are multiple terrain base layers, the terrain mask corresponding to each terrain base layer can be built independently or according to a pre-set association rule. At the same time, the terrain mask corresponding to each terrain base layer can be built sequentially in a preset order, or the terrain mask corresponding to each terrain base layer can be built separately and then stitched together.
[0050] When constructing the geomorphic base layer according to the geomorphic distribution rules, if there are multiple geomorphic base layers with overlapping parts, the following methods can be used: the later-generated geomorphic base layer covers the earlier-generated geomorphic base layer; the earlier-generated geomorphic base layer covers the later-generated geomorphic base layer; or a transitional method can be used. No specific restrictions are imposed here.
[0051] 103. Based on the terrain mask, perform material mixing on the basic terrain layer to obtain the corresponding terrain scene.
[0052] In this embodiment, the material rendering rules for each terrain base layer are pre-set and applied to the material shader. After the terrain mask corresponding to one or more terrain base layers is constructed, it is imported into the corresponding shader. The material rendering rules are used to perform layer blending on the corresponding terrain base layer to generate the terrain scene with the expected material effect.
[0053] The generation of terrain masks and the use of terrain masks for material blending of the terrain base layer can be handled separately. For example, terrain masks can be constructed using DCC (Digital Content Creation) tools such as Houdini and stored as data packages for later use. Then, when a terrain scene needs to be generated, the data package corresponding to the terrain mask can be imported into the game engine for material blending to generate the corresponding terrain scene.
[0054] In this embodiment of the invention, terrain data of the scene to be rendered is acquired; then, a terrain mask corresponding to the basic terrain layer in the scene to be rendered is constructed according to a preset terrain distribution rule, so that the terrain mask of each block in the scene to be rendered is uniformly constructed according to different types; finally, the corresponding terrain base layer can be mixed with materials according to the terrain mask to obtain the corresponding terrain scene. By using terrain distribution rules to replace block construction for terrain mask construction, the uniform construction of blocks of the same type in the game terrain scene is realized, thereby reducing the requirements for hardware performance and reducing the amount of resources required, thus improving the efficiency of game scene production, making large game terrain scenes suitable for mobile devices and easy to debug according to terrain distribution rules.
[0055] Specifically, the following embodiments provide two methods for edge optimization processing of the basic terrain layer:
[0056] In one implementation, when performing material blending on the terrain base layer, the border area between the terrain base layers can be determined based on the terrain mask, and the blending value between the pixel normal and vertex normal in the terrain base layer can be calculated based on the border area; based on the blending value, the terrain base layer is spatially offset, and the corresponding border area after the spatially offset is material blended to obtain the corresponding terrain scene.
[0057] In this embodiment, the masking data can determine the area of each terrain base layer, which can be represented by (0,1). In a terrain base layer, "1" represents the area occupied by that terrain base layer. Therefore, through the masking data corresponding to each terrain base layer, the border area between each terrain base layer can be determined. The masking data can determine the pixel normal and vertex normal. Then, based on the blending value of the two, a spatial angular offset is made to the terrain base layer, preferably in the Z direction, so that there is a more natural transition effect after the overlapping material of two terrain base layers is blended.
[0058] Specifically, if the Slope layer is adjacent to the Erosion layer, the angle of the Slope layer's material layer can be offset according to the Z-axis of the Pixel Normal and Vertex Normal blending values. In the Shader, the Erosion layer material and the Slope layer material are blended once to create a more natural transition effect.
[0059] In one implementation, after constructing the terrain mask corresponding to each terrain base layer, the edge information of each terrain mask can be determined, and each terrain mask can be used as a negative area in sequence; based on the negative area, edge noise can be added to each terrain mask in sequence to obtain a new terrain mask.
[0060] In this embodiment, since reading Pixel Normal can affect hardware performance, such as increasing resource consumption when used on mobile devices, optimization for terrain masking is further proposed. The edges of the terrain mask are processed to reduce hardware performance requirements while also optimizing the edges. For example, edge noise is added after creating the terrain mask in Houdini to achieve a more natural transition effect.
[0061] Specifically, taking the Gravel layer as an example, based on the actual mixing situation, if Gravel is considered the negative form and the adjacent terrain base layer is the Grass layer, then the Grass layer is considered the positive form, and the data calculated by the Gravel layer is the Base. The corresponding pseudocode can be:
[0062] Base1 = Expand(Base);
[0063] Base2 = Shrink(Base);
[0064] Gravel New =max(Base2, Base1-MakeNoise(Base1));
[0065] Among them, Gravel New This is the Gravel layer after adding edge noise.
[0066] When adding edge noise to the base terrain layer, there are two methods depending on the order of addition: The first method is to calculate the masking data of each base terrain layer and then use the masking data to uniformly add edge noise to the junctions between different base terrain layers in a preset order; The second method is to calculate the masking data of the base terrain layers in sequence. After calculating the masking data of the first and second base terrain layers, the masking data of the first and second base terrain layers is used to perform edge optimization at the junctions between the first and second base terrain layers. Then the masking data of the third base terrain layer is calculated, and the junctions with the first and second base terrain layers are optimized, and so on.
[0067] In this embodiment of the invention, when the terrain mask calculated according to the terrain distribution rules is used to create a terrain scene, the edges of each terrain base layer are relatively harsh. Therefore, edge optimization is performed on the junctions of the terrain base layers, including PixelNormal blending and edge noise processing, to make the junctions of the terrain base layers more natural.
[0068] Specifically, the following embodiments provide methods for constructing the corresponding basic landform layer according to various landform distribution rules:
[0069] Based on the terrain data, select the preset terrain distribution rules corresponding to the terrain base layer in the scene to be rendered. The terrain base layer includes at least one or more of the first base layer, the second base layer, the third base layer, and the fourth base layer.
[0070] Based on terrain data and using selected landform distribution rules, the corresponding landform base layer in the scene to be rendered is decomposed and calculated, and environmental simulation calculations are performed to obtain the corresponding landform mask.
[0071] In this embodiment, the terrain base layer in the scene to be rendered is constructed according to the corresponding preset terrain distribution rules. One terrain base layer corresponds to one terrain distribution rule. Here, the terrain base layer can include at least one or more of the first base layer, the second base layer, the third base layer and the fourth base layer, and no specific limitation is made here.
[0072] In addition, the terrain distribution rules include the decomposition calculation of the terrain base layer and the environmental simulation calculation. The decomposition calculation of the terrain base layer means dividing the area of the corresponding terrain base layer from the scene to be rendered, while the environmental simulation calculation means performing corresponding environmental simulations based on the natural formation conditions of different terrain base layers for the area of the terrain base layer obtained above, such as water flow distribution simulation, gravity simulation, flow field simulation, torsion calculation, fluid calculation, etc., to obtain a terrain mask that closely resembles the natural terrain.
[0073] In one implementation, if the landform base layer is the first base layer, then based on the terrain data, the flow field mask of the first landform base layer is calculated, and points are evenly scattered on the flow mask to obtain multiple original points; the tangent direction of each original point is calculated, and each original point is moved according to the tangent direction according to a preset speed to obtain simulated water flow distribution information; the original points in the simulated water flow partial map are mapped to the height map corresponding to the terrain data to obtain the landform mask corresponding to the first base layer.
[0074] In this embodiment, the first geomorphic base layer can be the Flow layer, representing the area of bare soil formed by rainwater erosion. Therefore, when performing decomposition calculations on the geomorphic base layer, a flow field mask is calculated, and data points are evenly scattered on this mask. These data points simulate rainwater moving downwards along the tangent direction of the corresponding elevation map of the terrain data, i.e., decomposition calculations are performed using environmental simulation. This process is repeated until these data points flow to a suitable position, thus obtaining the area corresponding to the Flow layer obtained by simulating rainwater erosion. For example, Figure 3 As shown, the method for calculating the tangent direction is as follows:
[0075] Grad=-volumegradient(1,0,@P);
[0076] Norm = cross(oldNorm, Grad), as shown in 301, is an example of the corresponding movement direction;
[0077] Norm = cross(Norm, oldNorm), as shown in 301, is an example of the corresponding movement direction;
[0078] Specifically, by uniformly scattering data points and shifting them downwards a certain distance according to the new Norm direction, and repeating this process, a simulated water flow distribution map can be obtained. This water flow distribution map is then mapped onto a height map, using the data points as units, to obtain the final terrain mask corresponding to the first base layer.
[0079] In one implementation, if the landform base layer is a second base layer, then according to the terrain data and a preset first slope, gravity calculation and flow field calculation are performed on the second base layer to obtain the geometric information corresponding to the second base layer; according to the geometric information corresponding to the second base layer, geometric regions smaller than a preset first area are removed from the second base layer; the geometric regions in the second base layer are distorted and the height map corresponding to the terrain data is returned to obtain the corresponding landform mask.
[0080] In this embodiment, the second base layer can be a Gravel layer, representing the scree area at the lower part of the rock slope where the slope is slightly steep. Therefore, it is necessary to first select an appropriate slope range (i.e., the first slope, which is suitable for relatively steep slopes, preferably 10° to 50°), and use this first slope as the base data to perform gravity calculations and flow field calculations (for example, using Houdini's built-in node algorithm). Then, the obtained data is converted into geometric information (a geometric shape composed of dense points, where when the distance between two points is less than a preset distance, they are used to form the same geometric shape). Then, the area of each small region in the second base layer is determined according to the geometric information, and small regions with smaller areas are removed. Finally, distortion processing is performed to make the terrain effect more natural, and the processed data is converted back to the height map corresponding to the terrain data to obtain the terrain mask corresponding to the second base layer.
[0081] In one implementation, if the landform base layer is the third base layer, then according to the terrain data and a preset second slope, the flow field simulation calculation is performed on the third base layer to obtain the regional data corresponding to the third base layer; the regional data corresponding to the third base layer is remapped to a preset numerical range to obtain the landform mask corresponding to the third base layer.
[0082] In this embodiment, the third base layer can be the Debris layer, which represents the dry soil area of a small depression where rainwater collects at low altitudes. This landform is easily formed on gentle slopes. Therefore, an appropriate slope range (i.e., the second slope, preferably a gentle slope of 0° to 30°) can be selected first. Then, flow field simulation calculations are performed based on the gentle slope as the base data. The calculated data is then remapped to a preset numerical range (preferably between 0 and 1) to obtain the landform mask corresponding to the third base layer.
[0083] Preferably, after performing flow field simulation calculations on the basic data of the gentle slope, further screening can be carried out to find a gentler area (the slope range of the gentler area is preferably 0° to 15°), making it closer to the dry soil area of the third base layer. The data of this area is then remapped so that its value is between 0 and 1, resulting in a landform mask corresponding to the third base layer that better matches the environmental simulation.
[0084] In one implementation, if the geomorphic base layer is the fourth base layer, then based on the terrain data, the interval range corresponding to the fourth base layer is calculated according to a preset third slope and a preset height; the occlusion mask corresponding to the interval range is calculated, and the occlusion area in the fourth base layer is determined based on the occlusion mask; the geometric information corresponding to the occlusion area is calculated, and geometric areas smaller than a preset second area are removed from the fourth base layer based on the geometric information corresponding to the occlusion area; distortion calculation and fluid calculation are performed on the geometric areas in the fourth base layer, and the difference between the interval range and the calculated geometric area is processed, and the geomorphic mask corresponding to the fourth base layer is calculated based on the result of the difference processing.
[0085] In this embodiment, the fourth base layer can be the Slope layer, which represents the rocky slope area mainly distributed on the steep surface at high altitudes. Therefore, when the fourth base layer is obtained by decomposing and calculating from the scene to be rendered, it is necessary to determine the height range and slope range of the fourth base layer. Specifically, an appropriate height range can be selected and pre-set according to the art requirements, or determined according to the maximum and minimum heights of the scene to be rendered in proportion to the height. The slope range (i.e., the third slope, which is preferably a steep slope of 20° to 70°) is also set to filter out the approximate range of the fourth base layer.
[0086] Furthermore, since the data in this interval contains a large number of closed areas, the simulation effect of the rock slope in the fourth base layer is insufficient, so further optimization is needed. The optimization method can be as follows: filter out the closed areas, convert them into geometric shapes, remove data with areas smaller than a preset threshold, perform distortion and fluid calculations on the new data, and finally subtract the new data from the original approximate interval data to remove unreasonable areas and improve the simulation effect of the rock slope in the fourth base layer.
[0087] Specifically, after decomposing and calculating the scene to be rendered, the region of the fourth base layer is obtained. For unreasonable locations in the simulation of the rock slope, such as a small area in the fourth base layer with a relatively flat lower edge that does not match the irregular edge of the rock slope, and the area is relatively large (e.g., tens of meters wide in actual scale), a mask can be calculated for the region of the fourth base layer, and occlusion calculation can be performed to obtain a new occlusion mask that is slightly larger than the slope range. Then, the occlusion mask is transformed into a geometric shape, and small structures (areas with an area smaller than the preset value) are deleted. Next, the edges of the geometric region are distorted and fluid calculations are performed to make the simulation effect more natural. Then, the data corresponding to the region of the fourth base layer is subtracted from the geometric shape after distortion and simulation calculations to obtain a new region with a steeper slope, making the lower edge of the unreasonable small area more natural, and the overall region is reduced. Finally, the obtained region is remapped onto the height map to calculate the terrain mask corresponding to the fourth base layer.
[0088] If the geomorphic base layer also includes a fifth base layer, then the geomorphic mask corresponding to the third base layer is subjected to simulated erosion processing; the geomorphic mask after simulated erosion processing is remapped to obtain the geomorphic mask corresponding to the fifth base layer.
[0089] In this embodiment, the fifth base layer can be the erosion layer, which is the sedimentary soil area at the low-altitude slope and the junction of grassland and other landform base layers. It is the area formed by the erosion of the slope layer by wind and water. Therefore, the slope layer is used as the base layer for the calculation of the fifth base layer. During the calculation, the landform mask obtained from the slope layer is used as the original data for erosion simulation. The landform mask corresponding to the fifth base layer can be obtained by remapping the data after erosion simulation.
[0090] If the basic landform layer also includes a sixth basic layer, then the edge of the fifth basic layer is extended to obtain the landform mask corresponding to the sixth basic layer.
[0091] In this embodiment, the sixth base layer can be a Grass layer, representing the grassland area demarcated along the edge of other gently sloping areas. Here, it can represent the edge of other landform base layers. That is, after calculating other landform base layers, the closed interval of the edge is the sixth base layer (Grass layer). One method for calculating the edge of the sixth base layer is to expand the landform mask of other landform base layers and then subtract the original landform mask. For example, for the Gravel layer, the specific edge calculation method can be expressed as: Edge of the sixth base layer = Expand(Gravel) - (Gravel).
[0092] In this embodiment of the invention, by formulating the terrain distribution rules for each different terrain base layer, the same type of blocks are uniformly constructed to obtain the corresponding terrain base layer, thereby reducing the amount of resources required for terrain scene production.
[0093] The game scene rendering method in the embodiments of the present invention has been described above. The game scene rendering apparatus in the embodiments of the present invention will be described below. Please refer to [link / reference]. Figure 4 One embodiment of the game scene rendering device in this invention includes:
[0094] The acquisition module 401 is used to acquire terrain data of the scene to be rendered;
[0095] Module 402 is used to construct a terrain mask corresponding to the terrain base layer that simulates the terrain distribution in the scene to be rendered, based on terrain data.
[0096] The material blending module 403 is used to blend materials on the terrain base layer based on the terrain mask to obtain the corresponding terrain scene.
[0097] In this embodiment of the invention, terrain data of the scene to be rendered is acquired; then, a terrain mask corresponding to the basic terrain layer in the scene to be rendered is constructed according to a preset terrain distribution rule, so that the terrain mask of each block in the scene to be rendered is uniformly constructed according to different types; finally, the corresponding terrain base layer can be mixed with materials according to the terrain mask to obtain the corresponding terrain scene. By using terrain distribution rules to replace block construction for terrain mask construction, the uniform construction of blocks of the same type in the game terrain scene is realized, thereby reducing the requirements for hardware performance and reducing the amount of resources required, thus improving the efficiency of game scene production, making large game terrain scenes suitable for mobile devices and easy to debug according to terrain distribution rules.
[0098] Please see Figure 5 Another embodiment of the game scene rendering device in this invention includes:
[0099] The acquisition module 401 is used to acquire terrain data of the scene to be rendered;
[0100] Module 402 is used to construct a terrain mask corresponding to the terrain base layer that simulates the terrain distribution in the scene to be rendered, based on terrain data.
[0101] The material blending module 403 is used to blend materials on the terrain base layer based on the terrain mask to obtain the corresponding terrain scene.
[0102] Specifically, the material mixing module 403 includes:
[0103] Offset unit 4031 is used to determine the border area between the terrain base layers based on the terrain mask, and to calculate the blending value between the pixel normal and the vertex normal in the terrain base layer according to the border area.
[0104] The material mixing unit 4032 is used to perform spatial angle offset on the terrain base layer according to the mixing value, and to perform material mixing on the corresponding border area after the spatial angle offset to obtain the corresponding terrain scene.
[0105] Specifically, the game scene rendering device also includes an edge optimization module 404, used for:
[0106] Determine the edge information of each terrain mask, and then treat each terrain mask as a negative area in turn.
[0107] Based on the negative region, edge noise is added to each terrain mask in turn to obtain a new terrain mask.
[0108] Specifically, builder module 402 is also used for:
[0109] Based on the terrain data, select the preset terrain distribution rules corresponding to the terrain base layer in the scene to be rendered. The terrain base layer includes at least one or more of the first base layer, the second base layer, the third base layer, and the fourth base layer.
[0110] Based on terrain data and using selected landform distribution rules, the corresponding landform base layer in the scene to be rendered is decomposed and calculated, and environmental simulation calculations are performed to obtain the corresponding landform mask.
[0111] Specifically, the building module 402 includes a first building unit 4021, used for:
[0112] If the basic landform layer is the first basic layer, then based on the terrain data, calculate the flow field mask of the first basic landform layer, and evenly sprinkle points on the flow mask to obtain multiple original points;
[0113] Calculate the tangent direction of each original point, and move each original point along the tangent direction according to the preset speed to obtain simulated water flow distribution information;
[0114] The original points in the simulated water flow map are mapped to the corresponding height map of the terrain data to obtain the landform mask corresponding to the first base layer.
[0115] Specifically, the building module 402 includes a second building unit 4022, used for:
[0116] If the geomorphic base layer is the second base layer, then according to the topographic data and the preset first slope, gravity calculation and flow field calculation are performed on the second base layer to obtain the geometric information corresponding to the second base layer.
[0117] Based on the geometric information corresponding to the second base layer, remove geometric regions smaller than the preset first area from the second base layer;
[0118] The geometric region in the second base layer is distorted and the corresponding height map of the terrain data is returned to obtain the corresponding terrain mask.
[0119] Specifically, the building module 402 includes a third building unit 4023, used for:
[0120] If the geomorphic base layer is the third base layer, then based on the topographic data and according to the preset second slope, the flow field simulation calculation is performed on the third base layer to obtain the regional data corresponding to the third base layer.
[0121] The regional data corresponding to the third base layer is remapped to a preset numerical range to obtain the terrain mask corresponding to the third base layer.
[0122] Specifically, building module 402 includes a fourth building unit 4024, used for:
[0123] If the basic landform layer is the fourth basic layer, then the range of the corresponding section of the fourth basic layer is calculated based on the topographic data, according to the preset third slope and preset height.
[0124] Calculate the occlusion mask corresponding to the interval range, and determine the occlusion region in the fourth base layer based on the occlusion mask;
[0125] Calculate the geometric information corresponding to the occluded region, and based on the geometric information corresponding to the occluded region, remove geometric regions smaller than the preset second area from the fourth basic layer;
[0126] Twist and fluid calculations are performed on the geometric region in the fourth base layer. The difference between the interval range and the calculated geometric region is calculated, and the terrain mask corresponding to the fourth base layer is calculated based on the difference.
[0127] Specifically, the fourth building unit 4024 is also used for:
[0128] If the basic geomorphic layer also includes a fifth basic layer, then the geomorphic masking corresponding to the third basic layer is subjected to simulated erosion treatment.
[0129] The landform mask after simulated erosion is remapped to obtain the landform mask corresponding to the fifth base layer.
[0130] Specifically, the fourth building unit 4024 is also used for:
[0131] If the basic terrain layer also includes a sixth basic layer, then the edge of the fifth basic layer is extended to obtain the terrain mask corresponding to the sixth basic layer.
[0132] In this embodiment of the invention, when the terrain mask calculated according to the terrain distribution rules is used to create a terrain scene, the edges of each terrain base layer are relatively harsh. Therefore, edge optimization is performed on the junctions of the terrain base layers, including PixelNormal blending and edge noise processing, to make the junctions of the terrain base layers more natural. In addition, by formulating terrain distribution rules for each different terrain base layer, the same type of blocks are uniformly constructed to obtain the corresponding terrain base layers, thereby reducing the amount of resources required for terrain scene creation.
[0133] above Figure 4 and Figure 5 The game scene rendering device in this embodiment of the invention will be described in detail from the perspective of modular functional entities. The game scene rendering device in this embodiment of the invention will be described in detail from the perspective of hardware processing.
[0134] Figure 6This is a schematic diagram of the structure of a game scene rendering device 600 provided in an embodiment of the present invention. The game scene rendering device 600 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 610 (e.g., one or more processors) and a memory 620, and one or more storage media 630 (e.g., one or more mass storage devices) for storing application programs 633 or data 632. The memory 620 and storage media 630 can be temporary or persistent storage. The program stored in the storage media 630 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the game scene rendering device 600. Furthermore, the processor 610 may be configured to communicate with the storage media 630 and execute the series of instruction operations in the storage media 630 on the game scene rendering device 600.
[0135] The game scene rendering device 600 may also include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input / output interfaces 660, and / or one or more operating systems 631, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will understand that... Figure 6 The illustrated game scene rendering device structure does not constitute a limitation on the game scene rendering device. It may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.
[0136] The present invention also provides a game scene rendering device. The computer device includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor performs the steps of the game scene rendering methods in the above embodiments.
[0137] The present invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the steps of a game scene rendering method.
[0138] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0139] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0140] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, 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. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for rendering game scenes, characterized in that, The game scene rendering method includes: Obtain the terrain data of the scene to be rendered; Based on the terrain data, construct a terrain mask corresponding to the terrain base layer that simulates the terrain distribution in the scene to be rendered. Based on the terrain mask, the base layer of the terrain is mixed with materials to obtain the corresponding terrain scene; The process of mixing materials on the base terrain layer based on the terrain mask to obtain the corresponding terrain scene includes: Based on the terrain mask, the border area between the terrain base layers is determined, and the blending value between the pixel normal and vertex normal in the terrain base layer is calculated according to the border area. Based on the mixing value, the basic landform layer is spatially offset, and the corresponding border area after the spatial offset is material-mixed to obtain the corresponding terrain scene.
2. The game scene rendering method according to claim 1, characterized in that, After constructing the terrain mask corresponding to the terrain base layer simulating the terrain distribution in the scene to be rendered based on the terrain data, the method further includes: Determine the edge information of each terrain mask, and then treat each terrain mask as a negative area in turn. Based on the negative region, edge noise is added sequentially to each terrain mask to obtain a new terrain mask.
3. The game scene rendering method according to claim 1, characterized in that, The step of constructing the terrain mask corresponding to the terrain base layer simulating the terrain distribution in the scene to be rendered, based on the terrain data, includes: Based on the terrain data, a preset terrain distribution rule corresponding to the terrain base layer in the scene to be rendered is selected, wherein the terrain base layer includes at least one or more of the first base layer, the second base layer, the third base layer and the fourth base layer; Based on the terrain data, the selected landform distribution rules are used to decompose and calculate the corresponding landform base layer in the scene to be rendered, and perform environmental simulation calculations to obtain the corresponding landform mask.
4. The game scene rendering method according to claim 3, characterized in that, Based on the terrain data, and using selected landform distribution rules, the corresponding landform base layer in the scene to be rendered is decomposed and calculated, and environmental simulation calculations are performed to obtain the corresponding landform mask, including: If the landform base layer is the first base layer, then based on the terrain data, the flow field mask of the first base layer is calculated, and points are evenly sprinkled on the flow field mask to obtain multiple original points; Calculate the tangent direction of each original point, and move each original point along the tangent direction according to a preset speed to obtain simulated water flow distribution information; Mapping the original points in the simulated water flow portion of the map to the height map corresponding to the terrain data yields the landform mask corresponding to the first base layer.
5. The game scene rendering method according to claim 3, characterized in that, The step of decomposing and simulating the corresponding terrain base layer in the scene to be rendered based on the terrain data and using selected terrain distribution rules to obtain the corresponding terrain mask also includes: If the landform base layer is the second base layer, then according to the terrain data and the preset first slope, gravity calculation and flow field calculation are performed on the second base layer to obtain the geometric information corresponding to the second base layer. Based on the geometric information corresponding to the second base layer, remove geometric regions smaller than the preset first area from the second base layer; The geometric region in the second base layer is distorted and the height map corresponding to the terrain data is returned to obtain the corresponding terrain mask.
6. The game scene rendering method according to claim 3, characterized in that, The step of decomposing and simulating the corresponding terrain base layer in the scene to be rendered based on the terrain data and using selected terrain distribution rules to obtain the corresponding terrain mask also includes: If the landform base layer is the third base layer, then according to the terrain data, the flow field simulation calculation is performed on the third base layer according to the preset second slope to obtain the regional data corresponding to the third base layer; The regional data corresponding to the third base layer is remapped to a preset numerical range to obtain the terrain mask corresponding to the third base layer.
7. The game scene rendering method according to claim 3, characterized in that, The step of decomposing and simulating the corresponding terrain base layer in the scene to be rendered based on the terrain data and using selected terrain distribution rules to obtain the corresponding terrain mask also includes: If the landform base layer is the fourth base layer, then based on the terrain data, the range corresponding to the fourth base layer is calculated according to the preset third slope and preset height. Calculate the occlusion mask corresponding to the interval range, and determine the occlusion region in the fourth base layer based on the occlusion mask; Calculate the geometric information corresponding to the occluded region, and based on the geometric information corresponding to the occluded region, remove geometric regions smaller than a preset second area from the fourth base layer; Twist calculation and fluid calculation are performed on the geometric region in the fourth base layer. The difference between the interval range and the calculated geometric region is calculated, and the terrain mask corresponding to the fourth base layer is calculated based on the result of the difference.
8. The game scene rendering method according to claim 7, characterized in that, After calculating the terrain mask corresponding to the fourth base layer based on the result of the difference processing, the method further includes: If the landform base layer also includes a fifth base layer, then the landform mask corresponding to the fourth base layer is subjected to simulated erosion treatment; The landform mask after simulated erosion is remapped to obtain the landform mask corresponding to the fifth base layer.
9. The game scene rendering method according to claim 8, characterized in that, After remapping the simulated erosion-processed terrain mask to obtain the terrain mask corresponding to the fifth base layer, the process further includes: If the basic terrain layer also includes a sixth basic layer, then the edge of the fifth basic layer is extended to obtain the terrain mask corresponding to the sixth basic layer.
10. A game scene rendering device, characterized in that, The game scene rendering device includes: The acquisition module is used to acquire terrain data of the scene to be rendered; The construction module is used to construct a terrain mask corresponding to the terrain base layer simulating the terrain distribution in the scene to be rendered, based on the terrain data. The material blending module is used to blend the materials of the terrain base layer based on the terrain mask to obtain the corresponding terrain scene. The material blending module is used to determine the border area between the terrain base layers based on the terrain mask, and calculate the blending value between the pixel normal and vertex normal in the terrain base layer according to the border area; according to the blending value, the terrain base layer is spatially offset, and the corresponding border area after the spatial angle offset is material blended to obtain the corresponding terrain scene.
11. A game scene rendering device, characterized in that, The game scene rendering device includes: a memory and at least one processor, wherein the memory stores instructions; The at least one processor invokes the instructions in the memory to cause the game scene rendering device to perform the steps of the game scene rendering method as described in any one of claims 1-9.
12. A computer-readable storage medium storing instructions thereon, characterized in that, When the instruction is executed by the processor, it implements the steps of the game scene rendering method as described in any one of claims 1-9.