Method and apparatus for generating scene terrain, storage medium, and electronic device
By creating and processing terrain models on planar geometry and baking terrain detail parameters in the game engine, the problems of inefficient terrain editing tools in the prior art and inability to adjust the effects in the engine are solved, and efficient scene terrain generation and customization are achieved.
Patent Information
- Application Number
- CN202111629357.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2041-12-28
AI Technical Summary
When the existing technology generates scene terrain in open world games, the engine's own map editing tools are inefficient and the brush effects are limited. Third-party software requires art to master a variety of software, and the production process is cumbersome and the effect cannot be adjusted directly in the engine.
By creating a first terrain model and a second terrain model on the plane geometry, digging the first terrain model down in the engine and lifting the second terrain model, a terrain file of the scene terrain is generated. Then, import these terrain files into the modeling engine to bake terrain details parameters locally in the engine based on the terrain files to generate terrain layer data.
It realizes flexible customization of scene terrain in the engine, solves the problem of not being able to flexibly adjust the terrain in the engine, and improves the production efficiency of scene terrain.
Smart Images

Figure CN114272609B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating scene terrain, a storage medium, and an electronic device. Background Art
[0002] In related technologies, the production of large world maps is a key link in the production of scenes for open world games (including but not limited to first-person shooters, massively multiplayer online games, adventure exploration puzzle games and other 3D games). In recent years, the support of mobile device performance and the development of engine technology have spawned more and more open world projects.
[0003] In the related technology, the methods of making world maps include: 1. Using the map editing tools that come with the engine (such as Unity's Terrain and Unreal Engine's Landscape); 2. Using third-party software to develop terrain assets and then importing them into the game engine (such as making terrain in software such as Gaia and Houdini); 3. Using 3D software to produce basic models, splicing terrain undulations in the engine, and then baking them remotely. The corresponding defects mainly include: the map editing tools that come with the engine have low iteration efficiency, limited brush effects, and unnatural terrain undulations and erosion. The terrain effects produced by terrain assets developed by third-party software are better than those of engine tools, but artists are required to master multiple software, and the production process is repetitive and cumbersome, and the effects cannot be adjusted directly in the engine. The terrain splicing method used in the self-developed Hou Tu framework has improved on the first two items, but is limited by the types of basic models produced, and only supports upward superposition. There are no tools to lower the terrain downward, and the operation is cumbersome when making trenching terrain.
[0004] With respect to the above-mentioned problems existing in the related technologies, no effective solutions have been found so far. Summary of the invention
[0005] The embodiments of the present invention provide a method and device for generating scene terrain, a storage medium, and an electronic device.
[0006] According to one embodiment of the present invention, a method for generating a scene terrain is provided, comprising: creating a first terrain model and a second terrain model on a plane geometric body; digging the first terrain model up and down on the plane geometric body, and raising the second terrain model, to generate a terrain file of the scene terrain; importing the terrain file into a modeling engine, and baking terrain detail parameters of the scene terrain locally in the modeling engine based on the terrain file, to generate terrain layer data of the scene terrain.
[0007] Optionally, creating a first terrain model and a second terrain model on a planar geometric body includes: building a basic model set on the planar geometric body; grouping the basic model set into the first terrain model and the second terrain model; storing the first terrain model in a first tool node, and storing the second terrain model in a second tool node, where the first tool node is used to export the terrain model to be excavated, and the second tool node is used to export the terrain model to be raised.
[0008] Optionally, creating a first terrain model and a second terrain model on a planar geometric body includes: in response to a drag instruction of a curve tool, drawing a curve on the planar geometric body to generate a terrain trend line, where the terrain trend line is used to indicate the scatter point range of the terrain model to be generated; obtaining the scatter point parameters of the terrain trend line, where the scatter point parameters include at least one of the following: a ramp curve graph of the scatter point range, the number of models, and a model scaling parameter; generating the first terrain model and the second terrain model on the planar geometric body using the scatter point parameters.
[0009] Optionally, excavating the first terrain model and raising the second terrain model on the planar geometric body to generate a terrain file of the scene terrain includes: determining the lowest surface value of the first terrain model and determining the highest surface value of the second terrain model; reading a first initial terrain voxel set of the first terrain model and reading a second initial terrain voxel set of the second terrain model; merging each terrain voxel in the first initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the lowest surface value to obtain a first intermediate terrain voxel set, and merging each terrain voxel in the first intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the first terrain model; merging each terrain voxel in the second initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the highest surface value to obtain a second intermediate terrain voxel set, and merging each terrain voxel in the second intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the second terrain model; generating a terrain file of the scene terrain based on the terrain height value of the first terrain model and the terrain height value of the second terrain model.
[0010] Optionally, terrain detail parameters of the scene terrain are baked locally in the modeling engine based on the terrain file. Generating terrain layer data of the scene terrain includes: generating basic terrain data of the scene terrain locally in the modeling engine using the terrain file; performing terrain distortion on the basic terrain locally in the modeling engine to generate a first detailed terrain; performing surface erosion on the first detailed terrain locally in the modeling engine to generate a second detailed terrain; and locally allocating texture maps to the second detailed terrain in the modeling engine to generate the terrain layer data of the scene terrain.
[0011] Optionally, performing terrain distortion on the basic terrain locally in the modeling engine includes: performing blurring on the basic terrain locally in the modeling engine to obtain a first intermediate model; dividing the first intermediate model into a first geometric body and a second geometric body; sequentially performing distortion processing and noise processing on the first geometric body, and performing custom modification on the second geometric body.
[0012] Optionally, performing surface erosion on the first detailed terrain locally in the modeling engine includes: determining a first geometric body and a second geometric body in the first detailed terrain, where the second geometric body corresponds to a terrain area with custom modification; generating an erosion protection mask on the second geometric body; obtaining preset erosion parameters, and performing erosion processing on the surface layer of the first detailed terrain using the erosion parameters.
[0013] Optionally, locally allocating texture maps to the second detailed terrain in the modeling engine includes: locally responding to an operation instruction of a curve tool in the modeling engine, and enclosing a number of target areas in the second detailed terrain, where each target area corresponds to a landform range of a landform type; for each target area, searching for a texture map that matches the landform type of the target area; and baking the texture map in the target area.
[0014] According to another embodiment of the present invention, a device for generating a scene terrain is provided, including: a creation module for creating a first terrain model and a second terrain model on a planar geometric body; a processing module for excavating the first terrain model and elevating the second terrain model on the planar geometric body to generate a terrain file of the scene terrain; and a generation module for importing the terrain file into a modeling engine, and baking terrain detail parameters of the scene terrain locally in the modeling engine based on the terrain file to generate terrain layer data of the scene terrain.
[0015] Optionally, the creation module includes: a building unit configured to build a basic model set on the planar geometric body; a grouping unit configured to group the basic model set into the first terrain model and the second terrain model; and a storage unit configured to store the first terrain model into a first tool node and store the second terrain model into a second tool node, where the first tool node is used to export the terrain model to be excavated, and the second tool node is used to export the terrain model to be elevated.
[0016] Optionally, the creation module includes: a first generation unit configured to draw a curve on the planar geometric body in response to a dragging instruction of a curve tool, and generate a terrain trend line, where the terrain trend line is used to indicate the scatter point range of the terrain model to be generated; an acquisition unit configured to acquire the scatter point parameters of the terrain trend line, where the scatter point parameters include at least one of the following: a ramp curve graph of the scatter point range, the number of models, and a model scaling parameter; and a second generation unit configured to generate the first terrain model and the second terrain model on the planar geometric body by using the scatter point parameters.
[0017] Optionally, the processing module includes: a determination unit configured to determine the lowest surface value of the first terrain model and determine the highest surface value of the second terrain model; a reading unit configured to read a first initial terrain voxel set of the first terrain model and read a second initial terrain voxel set of the second terrain model; a processing unit configured to merge each terrain voxel in the first initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the lowest surface value to obtain a first intermediate terrain voxel set, and merge each terrain voxel in the first intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the first terrain model; merge each terrain voxel in the second initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the highest surface value to obtain a second intermediate terrain voxel set, and merge each terrain voxel in the second intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the second terrain model; and a generation unit configured to generate a terrain file of the scene terrain based on the terrain height value of the first terrain model and the terrain height value of the second terrain model.
[0018] Optionally, the generating module includes: a first generating unit configured to generate basic terrain data of the scene terrain locally in the modeling engine by using the terrain file; a second generating unit configured to perform terrain distortion on the basic terrain locally in the modeling engine to generate first detailed terrain; a third generating unit configured to perform surface erosion on the first detailed terrain locally in the modeling engine to generate second detailed terrain; and a fourth generating unit configured to allocate texture maps for the second detailed terrain locally in the modeling engine to generate terrain layer data of the scene terrain.
[0019] Optionally, the second generating unit includes: a first processing subunit configured to perform blurring processing on the basic terrain locally in the modeling engine to obtain a first intermediate model; a dividing subunit configured to divide the first intermediate model into a first geometric body and a second geometric body; and a second processing subunit configured to perform distortion processing and noise processing on the first geometric body in sequence and perform custom modification on the second geometric body.
[0020] Optionally, the third generating unit includes: a determining subunit configured to determine a first geometric body and a second geometric body in the first detailed terrain, where the second geometric body corresponds to a terrain area with custom modification; a generating subunit configured to generate an erosion protection mask on the second geometric body; and a processing subunit configured to obtain preset erosion parameters and perform erosion processing on the surface layer of the first detailed terrain by using the erosion parameters.
[0021] Optionally, the fourth generating unit includes: a circumscribing subunit configured to circumscribe a plurality of target areas in the second detailed terrain locally in the modeling engine in response to an operation instruction of a curve tool, where each target area corresponds to a landform range of a landform type; a searching subunit configured to search for a texture map matching the landform type of each target area for each target area; and a baking subunit configured to bake the texture map in the target area.
[0022] According to another embodiment of the present invention, there is also provided a storage medium storing a computer program, where the computer program is configured to execute the steps in any one of the above method embodiments when running.
[0023] According to another embodiment of the present invention, there is also provided an electronic device including a memory and a processor, where the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0024] Through the present invention, a first terrain model and a second terrain model are created on a planar geometric body; the first terrain model is dug down on the planar geometric body, and the second terrain model is elevated to generate a terrain file of the scene terrain; the terrain file is imported into a modeling engine, and terrain detail parameters of the scene terrain are baked locally in the modeling engine based on the terrain file to generate terrain layer data of the scene terrain. By generating the terrain file of the scene terrain with the dug-down and elevated terrain models and baking the terrain detail parameters in the terrain file, flexible customization of the scene terrain in the engine is achieved, the technical problem that the terrain cannot be flexibly adjusted in the engine in the related art is solved, and the production efficiency of the scene terrain is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the present invention, form a part of this application, and the schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:
[0026] Figure 1 is a hardware structure block diagram of a generation server for a scene terrain according to an embodiment of the present invention;
[0027] Figure 2 is a flowchart of a method for generating a scene terrain according to an embodiment of the present invention;
[0028] Figure 3 is a schematic diagram of generating a scene terrain according to an embodiment of the present invention;
[0029] Figure 4 is a schematic diagram of creating a first terrain model and a second terrain model by a curve tool according to an embodiment of the present invention;
[0030] Figure 5 is a schematic diagram of performing terrain detail processing on a scene terrain according to an embodiment of the present invention;
[0031] Figure 6 is a structure block diagram of a generation device for a scene terrain according to an embodiment of the present invention;
[0032] Figure 7 is a structure diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0033] To enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application. It should be noted that, without conflict, the embodiments in this application and the features in the embodiments can be combined with each other.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances, so that the embodiments of this application described here can be implemented in an order different from those illustrated or described here. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0035] Embodiment 1
[0036] The method embodiment provided in the first embodiment of this application can be executed on a mobile phone, a tablet, a server, a computer or a similar electronic terminal. Taking running on a server as an example, Figure 1 is a hardware structure block diagram of a generation server for a scenario terrain in an embodiment of the present invention. As Figure 1 shown, the server may include one or more ( Figure 1 only one is shown in the figure) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the above-mentioned server may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned server. For example, the server may further include more or fewer components than those shown in Figure 1 the figure, or have a different configuration from that shown in Figure 1 the figure.
[0037] The memory 104 can be used to store server programs, for example, software programs and modules of application software, such as a server program corresponding to a method for generating scene terrain in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the server program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. In this embodiment, the processor 104 is used to respond to human-computer interaction instructions and game strategies, and control the target virtual character to perform specified operations to complete the game task. The memory 104 is used to store program scripts, configuration information, attribute information of virtual characters, etc. of electronic games.
[0038] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0039] Optionally, the input-output device 108 further includes a human-computer interaction screen for obtaining human-computer interaction instructions through a human-computer interaction interface and for presenting images in a virtual scene;
[0040] In this embodiment, a method for generating a scene terrain is provided. Figure 2 FIG. 1 is a flow chart of a method for generating a scene terrain according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0041] Step S202, creating a first terrain model and a second terrain model on the plane geometric body;
[0042] Optionally, this embodiment can be applied to virtual scenes such as virtual game scenes, virtual teaching scenes, virtual demonstration scenes, etc., and the virtual scene includes multiple scene objects, such as terrain, buildings, etc. In this embodiment, the virtual scene is taken as an example of a virtual game scene.
[0043] Optionally, when the first terrain model and the second terrain model are created, they can be created using the same or different terrain models. The first terrain model is the terrain model to be dug down, and the second terrain model is the terrain model to be raised. What is generated is a model resource, and the resource type is mesh (grid).
[0044] Step S204: Dig down the first terrain model on the planar geometric body and raise the second terrain model to generate a terrain file for the scene terrain;
[0045] In this embodiment, for the raising, the terrain height is updated at the top of the second terrain model, and for the digging down, the terrain height is updated at the bottom of the first terrain model.
[0046] Step S206: Import the terrain file into the modeling engine, and bake the terrain detail parameters of the scene terrain locally in the modeling engine based on the terrain file to generate terrain layer data for the scene terrain.
[0047] In this embodiment, the detail parameters are the detail parameters configured or generated during the preprocessing of the scene terrain after digging down and raising, such as terrain distortion processing, surface erosion processing, and texture mapping processing.
[0048] Through the above steps, the first terrain model and the second terrain model are created on the planar geometric body; the first terrain model is dug down on the planar geometric body and the second terrain model is raised to generate a terrain file for the scene terrain; the terrain file is imported into the modeling engine, and the terrain detail parameters of the scene terrain are baked locally in the modeling engine based on the terrain file to generate terrain layer data for the scene terrain. By generating a terrain file for the scene terrain with the dug-down and raised terrain models and baking the terrain detail parameters in the terrain file, the flexible customization of the scene terrain in the engine is realized, the technical problem that the terrain cannot be flexibly adjusted in the engine in the related technology is solved, and the production efficiency of the scene terrain is improved.
[0049] In this embodiment, a preset map editing component (such as Unity) or a mountain scatter tool can be used to build a basic terrain model, and the first terrain model and the second terrain model are created on the planar geometric body.
[0050] In an implementation manner of this embodiment, creating the first terrain model and the second terrain model on the planar geometric body includes: building a basic model set on the planar geometric body; grouping the basic model set into the first terrain model and the second terrain model; storing the first terrain model in a first tool node, and storing the second terrain model in a second tool node, where the first tool node is used to export the terrain model to be dug down, and the second tool node is used to export the terrain model to be raised.
[0051] In this embodiment, referring to the preset design drawing of the target scene terrain, a basic model set is built using an engine modeling tool. After modeling, all the models are divided into two groups. One group is used to raise the terrain, and the other group is used to lower the terrain. The two groups of models are stored in two nodes of the tool control panel (such as the hierarchical management panel) for later use. In one example, the first terrain model and the second terrain model are identified using a specific color or style. For example, the red model represents the terrain to be dug down, and the green model represents the terrain to be raised. The models to raise the terrain are stored under the Add node (the first tool node) of the engine modeling tool, and the models to lower the terrain (red) are stored under the Sub node (the second tool node). It also supports raising and lowering the terrain within the engine, easily creating landforms such as valleys, deep pits, rivers, and lakes. Among them, in the layout tab: SizeX sets the terrain size. Drag and drop into the Add node in the Add panel and into the Sub node in the Sub panel. In this way, the basic model is imported into the tool. After the settings are completed, without clicking any button, a sub-node is automatically generated for the terrain under the tool node.
[0052] Figure 3 It is a schematic diagram of generating the scene terrain in an embodiment of the present invention. First, a basic model set is built and grouped on a planar geometric body, and then the first terrain model is dug down and the second terrain model is raised.
[0053] In another embodiment of this embodiment, creating the first terrain model and the second terrain model on the planar geometric body includes: responding to the dragging instruction of the curve tool, drawing a curve on the planar geometric body to generate a terrain trend line, where the terrain trend line is used to indicate the scattering range of the terrain model to be generated; obtaining the scattering parameters of the terrain trend line, where the scattering parameters include at least one of the following: the ramp curve graph of the scattering range, the number of models, and the model scaling parameter; generating the first terrain model and the second terrain model on the planar geometric body using the scattering parameters.
[0054] In this embodiment, a custom mountain scatter tool is used. First, the curve tool of the model engine is used to drag and extend curves on the terrain, and then the number, position, and size of the mountain peaks are adjusted by adjusting the parameters on the tool panel, simplifying the production process of the first terrain model and the second terrain model. The implementation process of this embodiment can be integrated into a procedural mountain tool. The input sources of this procedural mountain tool include: a configuration table of the path string of the mountain peak model in the engine for reading mountain peak resources; the curves dragged out in the engine for generating the mountain range; and the parameter settings (parameter panel diagram) exposed on the tool panel, including the ramp curve graph of the scatter range, the number of mountain bodies, the minimum scale, the maximum scale, the uniform scale, and other parameters. The output is the mountains arranged on the map. By using the curve tool of this embodiment, the positions and sizes of a preset number of mountain peaks can be directly adjusted through the curves to form a mountain range.
[0055] Figure 4 It is a schematic diagram of creating the first terrain model and the second terrain model through the curve tool in an embodiment of the present invention.
[0056] In this embodiment, the first terrain model is dug down and the second terrain model is raised on the plane geometric body to generate a terrain file of the scene terrain, including: determining the lowest surface value of the first terrain model and determining the highest surface value of the second terrain model; reading the first initial terrain voxel set of the first terrain model and reading the second initial terrain voxel set of the second terrain model; merging each terrain voxel in the first initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the lowest surface value to obtain a first intermediate terrain voxel set, and merging each terrain voxel in the first intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the first terrain model; merging each terrain voxel in the second initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the highest surface value to obtain a second intermediate terrain voxel set, and merging each terrain voxel in the second intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the second terrain model; generating the terrain file of the scene terrain based on the terrain height value of the first terrain model and the terrain height value of the second terrain model.
[0057] Mapping the model into the terrain file of the map editing component. Mapping means that the height of the terrain is calculated for each terrain voxel according to the highest surface of the corresponding "raised" geometric body and the lowest surface of the corresponding "dug-down" geometric body. The calculation process of raising and digging down in the digital asset production software is shown in the following figure. First, each voxel is merged based on the maximum value in the Y direction, and then each voxel is merged based on the minimum value in the Y direction to generate the terrain file of the scene terrain.
[0058] In an implementation manner of this embodiment, based on the terrain file, baking terrain detail parameters of the scene terrain locally in the modeling engine, and generating terrain layer data of the scene terrain includes:
[0059] S11, generating basic terrain data of the scene terrain locally in the modeling engine using the terrain file;
[0060] S12, performing terrain distortion on the basic terrain locally in the modeling engine to generate a first detailed terrain;
[0061] In an example, performing terrain distortion on the basic terrain locally in the modeling engine includes: performing a blur process on the basic terrain locally in the modeling engine to obtain a first intermediate model; dividing the first intermediate model into a first geometric body and a second geometric body; sequentially performing a distortion process and a noise process on the first geometric body, and performing a custom modification on the second geometric body.
[0062] This embodiment uses the baking interface of the scene production engine to access a custom tool, adding detailed deformation to the basic terrain generated by modeling; and performing erosion on the terrain with detailed deformation.
[0063] The terrain distortion component of this embodiment includes nodes such as blur, distort, noise, and object_merge nodes. During the detailed deformation process, through the superposition of nodes such as blur, distort, and noise, preliminary results of removing sharp corners, distorting edges, and natural undulations of the plane are obtained respectively. Among them, the role of the object_merge node is to access the model passed in when modifying the terrain for the second time. Since the distort and noise nodes have a relatively random effect and may cause destructive deformation to key positions, when the user needs to precisely control certain areas (the second geometric body), the geometric body placed in the map editing component can be accessed through object_merge to modify the terrain change degree at the access position, achieving the purpose of flexibly and precisely controlling the detailed deformation.
[0064] The above example regarding terrain distortion includes two aspects. The first is to solve the problem of too hard edges of the geometric body by combining blur and multiple distort and noise calculations. The second is to support precise secondary modification of the second geometric body for the distortion result through object_merge to meet the design requirements.
[0065] S12, performing surface erosion on the first detailed terrain locally in the modeling engine to generate a second detailed terrain;
[0066] In one example, performing surface erosion on the first detailed terrain locally in the modeling engine includes: determining a first geometric body and a second geometric body in the first detailed terrain, where the second geometric body corresponds to a terrain area with custom modifications; generating an erosion protection mask on the second geometric body; obtaining preset erosion parameters, and performing erosion processing on the surface layer of the first detailed terrain using the erosion parameters.
[0067] This example uses preset erosion rules to perform surface erosion. This embodiment generates a mask for the geometric body (the second geometric body) used for secondary modification, and also retains the areas that need to be precisely controlled to avoid damage caused by global erosion; the embodiment also pre-configures preset erosion parameters and exposes the key parameters to the scene production engine.
[0068] S13. Locally allocate texture maps for the second detailed terrain in the modeling engine to generate terrain layer data of the scene terrain.
[0069] In one example, locally allocating texture maps for the second detailed terrain in the modeling engine includes: locally responding to an operation instruction of a curve tool in the modeling engine, and enclosing a number of target areas in the second detailed terrain, where each target area corresponds to a landform range of a landform type; for each target area, searching for a texture map that matches the landform type of the target area; baking the texture map in the target area.
[0070] This example uses preset surface mapping rules to allocate texture maps for the surface and outputs terrain layer data in a specified format common to digital asset production software, such as data in the.terrainlayer format commonly used by map editing components. When allocating texture maps for the terrain, the curve tool in the production engine is used to enclose areas during area division, so that lines are used instead of hand-drawn brushes to precisely outline the landform range. When modifying, there is no need to smear too much, and only the control points of the curve need to be dragged to adjust the landform range. At the same time, this embodiment completes the conversion of model - terrain - erosion through local baking within the engine, solving the problem of not being able to intuitively see the adjusted effect within the engine.
[0071] Figure 5 It is a schematic diagram of the terrain detail processing of the scene terrain in the embodiment of the present invention. First, the basic terrain is distorted, then surface erosion is performed, and finally texture mapping is carried out to integrate the snowfield and lawn areas with the original landform.
[0072] The solution of this embodiment is different from other large world generation tools and processes. When applied to game projects, it can be perfectly compatible with the official data format of map editing tools, reducing the learning costs of artists and level designers and enabling the stable and smooth production of resources. This embodiment expansively supports the need for artists and level designers to precisely modify the terrain by editing models during actual application. Level designers can use the tools of this solution to modify the terrain until they are satisfied, avoiding overly strong terrain programmability and randomness and weak controllability of designers, which may prevent it from being implemented in the final project.
[0073] In the engine, PDG (Procedural Dependency Graph, literally translated as procedural dependency graph) is used to bake terrain details, adding basic details - adding erosion - adding texture maps. The parameters of the walking iteration are baked locally according to the general parameters preset in digital asset production software, and it supports exposing the parameters for adjustment in the engine. From building the basic model to baking the surface texture map, all can be directly adjusted within the engine to produce assets. It uses the built-in functions of digital asset production software and presets a set of parameters with relatively ideal default effects according to the level design requirements, and packages them into the tools of the map editing component.
[0074] The beneficial effects of the present invention are as follows: It solves the defects of the existing technical solutions and retains the advantages of the existing production solutions, being compatible with the official data format of map editing components. At the same time, it has the following technical effects: It solves the problem of being unable to flexibly adjust the terrain within the engine. It solves the problem of being unable to intuitively view the effects after adjustment within the engine. This solution performs local baking within the engine to complete the conversion of model - terrain - erosion. It solves the problem of being unable to programmatically control the distribution of mountain peaks. It further solves the problem of the distribution of the basic model. For example, when a user uses multiple modeled mountain peaks to create a mountain range, they need to adjust the position and size of each mountain peak in sequence. The procedural mountain range tool can directly adjust the positions and sizes of dozens of mountain peaks through curves to form a mountain range.
[0075] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the existing technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.
[0076] Embodiment 2
[0077] In this embodiment, a device for generating a scene terrain is further provided to implement the above-mentioned embodiments and preferred implementation manners, which have been described and will not be repeated here. As used hereinafter, the term "module" may be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0078] Figure 6 is a structural block diagram of a device for generating a scene terrain according to an embodiment of the present invention. As Figure 6 shown, the device includes: a creation module 60, a processing module 62, and a generation module 64. Among them,
[0079] The creation module 60 is used to create a first terrain model and a second terrain model on a planar geometric body;
[0080] The processing module 62 is used to dig down the first terrain model and raise the second terrain model on the planar geometric body to generate a terrain file of the scene terrain;
[0081] The generation module 64 is used to import the terrain file into a modeling engine, and bake terrain detail parameters of the scene terrain locally in the modeling engine based on the terrain file to generate terrain layer data of the scene terrain.
[0082] Optionally, the creation module includes: a building unit for building a basic model set on the planar geometric body; a grouping unit for grouping the basic model set into the first terrain model and the second terrain model; a storage unit for storing the first terrain model in a first tool node and storing the second terrain model in a second tool node, where the first tool node is used to export the terrain model to be dug down, and the second tool node is used to export the terrain model to be raised.
[0083] Optionally, the creation module includes: a first generation unit for responding to a drag instruction of a curve tool to draw a curve on the planar geometric body to generate a terrain trend line, where the terrain trend line is used to indicate the scatter point range of the terrain model to be generated; an acquisition unit for acquiring scatter point parameters of the terrain trend line, where the scatter point parameters include at least one of the following: a ramp curve graph of the scatter point range, the number of models, and a model scaling parameter; a second generation unit for generating the first terrain model and the second terrain model on the planar geometric body by using the scatter point parameters.
[0084] Optionally, the processing module includes: a determination unit configured to determine the lowest surface value of the first terrain model and the highest surface value of the second terrain model; a reading unit configured to read a first set of initial terrain voxels of the first terrain model and a second set of initial terrain voxels of the second terrain model; a processing unit configured to merge each terrain voxel in the first set of initial terrain voxels based on the maximum value of the longitudinal coordinate according to the lowest surface value to obtain a first set of intermediate terrain voxels, and merge each terrain voxel in the first set of intermediate terrain voxels based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the first terrain model; merge each terrain voxel in the second set of initial terrain voxels based on the maximum value of the longitudinal coordinate according to the highest surface value to obtain a second set of intermediate terrain voxels, and merge each terrain voxel in the second set of intermediate terrain voxels based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the second terrain model; a generation unit configured to generate a terrain file of the scene terrain based on the terrain height value of the first terrain model and the terrain height value of the second terrain model.
[0085] Optionally, the generation module includes: a first generation unit configured to generate basic terrain data of the scene terrain locally in the modeling engine using the terrain file; a second generation unit configured to perform terrain distortion on the basic terrain locally in the modeling engine to generate a first detailed terrain; a third generation unit configured to perform surface erosion on the first detailed terrain locally in the modeling engine to generate a second detailed terrain; a fourth generation unit configured to allocate texture maps to the second detailed terrain locally in the modeling engine to generate terrain layer data of the scene terrain.
[0086] Optionally, the second generation unit includes: a first processing subunit configured to perform blurring processing on the basic terrain locally in the modeling engine to obtain a first intermediate model; a division subunit configured to divide the first intermediate model into a first geometric body and a second geometric body; a second processing subunit configured to sequentially perform distortion processing and noise processing on the first geometric body and perform custom modification on the second geometric body.
[0087] Optionally, the third generation unit includes: a determination subunit configured to determine a first geometric body and a second geometric body in the first detailed terrain, where the second geometric body corresponds to a terrain area with custom modification; a generation subunit configured to generate an erosion protection mask on the second geometric body; a processing subunit configured to obtain preset erosion parameters and perform erosion processing on the surface layer of the first detailed terrain using the erosion parameters.
[0088] Optionally, the fourth generation unit includes: an encircling stator subunit, configured to locally respond to an operation instruction of a curve tool in the modeling engine and encircle a plurality of target regions in the second detailed terrain, where each target region corresponds to a terrain range of a terrain type; a searching subunit, configured to search for a texture map matching the terrain type of each target region; and a baking subunit, configured to bake the texture map in the target region.
[0089] It should be noted that the above-mentioned modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited thereto: the above-mentioned modules are all located in the same processor; or, the above-mentioned modules are separately located in different processors in any combination form.
[0090] Embodiment 3
[0091] The embodiment of the present application further provides an electronic device. Figure 7 It is a structural diagram of an electronic device according to an embodiment of the present invention, as Figure 7 shown, including a processor 71, a communication interface 72, a memory 73, and a communication bus 74. Among them, the processor 71, the communication interface 72, and the memory 73 complete mutual communication through the communication bus 74. The memory 73 is used to store a computer program.
[0092] When the processor 71 executes the program stored on the memory 73, the following steps are implemented: creating a first terrain model and a second terrain model on a planar geometric body; excavating the first terrain model and elevating the second terrain model on the planar geometric body to generate a terrain file of the scene terrain; importing the terrain file into a modeling engine, and baking terrain detail parameters of the scene terrain locally in the modeling engine based on the terrain file to generate terrain layer data of the scene terrain.
[0093] Optionally, creating a first terrain model and a second terrain model on a planar geometric body includes: building a basic model set on the planar geometric body; grouping the basic model set into the first terrain model and the second terrain model; storing the first terrain model in a first tool node, and storing the second terrain model in a second tool node, where the first tool node is used to export the terrain model to be excavated, and the second tool node is used to export the terrain model to be elevated.
[0094] Optionally, creating the first terrain model and the second terrain model on the planar geometric body includes: responding to the dragging instruction of the curve tool, drawing a curve on the planar geometric body to generate a terrain trend line, where the terrain trend line is used to indicate the scatter point range of the terrain model to be generated; obtaining the scatter point parameters of the terrain trend line, where the scatter point parameters include at least one of the following: the ramp curve graph of the scatter point range, the number of models, and the model scaling parameter; generating the first terrain model and the second terrain model on the planar geometric body using the scatter point parameters.
[0095] Optionally, excavating the first terrain model downward and elevating the second terrain model on the planar geometric body to generate a terrain file of the scene terrain includes: determining the lowest surface value of the first terrain model and determining the highest surface value of the second terrain model; reading the first initial terrain voxel set of the first terrain model and reading the second initial terrain voxel set of the second terrain model; merging each terrain voxel in the first initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the lowest surface value to obtain a first intermediate terrain voxel set, and merging each terrain voxel in the first intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the first terrain model; merging each terrain voxel in the second initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the highest surface value to obtain a second intermediate terrain voxel set, and merging each terrain voxel in the second intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the second terrain model; generating the terrain file of the scene terrain based on the terrain height value of the first terrain model and the terrain height value of the second terrain model.
[0096] Optionally, baking the terrain detail parameters of the scene terrain locally in the modeling engine based on the terrain file to generate the terrain layer data of the scene terrain includes: generating the basic terrain data of the scene terrain locally in the modeling engine using the terrain file; performing terrain distortion on the basic terrain locally in the modeling engine to generate a first detailed terrain; performing surface erosion on the first detailed terrain locally in the modeling engine to generate a second detailed terrain; allocating texture maps to the second detailed terrain locally in the modeling engine to generate the terrain layer data of the scene terrain.
[0097] Optionally, performing terrain distortion on the basic terrain locally in the modeling engine includes: performing blurring processing on the basic terrain locally in the modeling engine to obtain a first intermediate model; dividing the first intermediate model into a first geometric body and a second geometric body; performing distortion processing and noise processing on the first geometric body in sequence, and performing custom modification on the second geometric body.
[0098] Optionally, performing surface erosion on the first detailed terrain locally in the modeling engine includes: determining a first geometric body and a second geometric body in the first detailed terrain, where the second geometric body corresponds to a terrain area with custom modifications; generating an erosion protection mask on the second geometric body; obtaining preset erosion parameters, and performing erosion processing on the surface layer of the first detailed terrain using the erosion parameters.
[0099] Optionally, allocating texture maps for the second detailed terrain locally in the modeling engine includes: locally in the modeling engine, in response to an operation instruction of a curve tool, delineating a number of target areas in the second detailed terrain, where each target area corresponds to a geomorphic range of a geomorphic type; for each target area, searching for a texture map that matches the geomorphic type of the target area; baking the texture map in the target area.
[0100] The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only a thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.
[0101] The communication interface is used for communication between the above terminal and other devices.
[0102] The memory may include a Random Access Memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0103] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU for short), a Network Processor (NP for short), etc.; it may also be a Digital Signal Processor (DSP for short), an Application Specific Integrated Circuit (ASIC for short), a Field-Programmable Gate Array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0104] In another embodiment provided by this application, a computer-readable storage medium is further provided. Instructions are stored in the computer-readable storage medium. When it runs on a computer, it causes the computer to execute the method for generating the scene terrain described in any one of the above embodiments.
[0105] In another embodiment provided by this application, a computer program product containing instructions is further provided. When it runs on a computer, it causes the computer to execute the method for generating the scene terrain described in any one of the above embodiments.
[0106] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of this application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that the computer can access, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a Solid State Disk (SSD)).
[0107] The serial numbers of the embodiments of the present application above are only for description and do not represent the superiority or inferiority of the embodiments.
[0108] In the above embodiments of the present application, the descriptions of the respective embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0109] In the several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of units or modules can be in an electrical or other form.
[0110] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0111] In addition, the functional units in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0112] If the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or 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 for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The foregoing storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks or optical discs and other various media that can store program codes.
[0113] The above are only the preferred embodiments of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.
Claims
1. A method for generating a scene terrain, characterized in that, it includes: creating a first terrain model and a second terrain model on a planar geometric body; excavating the first terrain model on the planar geometric body and elevating the second terrain model to generate a terrain file of the scene terrain; importing the terrain file into a modeling engine, and locally baking terrain detail parameters of the scene terrain based on the terrain file in the modeling engine to generate terrain layer data of the scene terrain; wherein, excavating the first terrain model on the planar geometric body and elevating the second terrain model to generate a terrain file of the scene terrain includes: determining the lowest surface value of the first terrain model and determining the highest surface value of the second terrain model; reading a first initial terrain voxel set of the first terrain model and reading a second initial terrain voxel set of the second terrain model; merging each terrain voxel in the first initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the lowest surface value to obtain a first intermediate terrain voxel set, and merging each terrain voxel in the first intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the first terrain model; merging each terrain voxel in the second initial terrain voxel set based on the maximum value of the longitudinal coordinate according to the highest surface value to obtain a second intermediate terrain voxel set, and merging each terrain voxel in the second intermediate terrain voxel set based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the second terrain model; generating a terrain file of the scene terrain based on the terrain height value of the first terrain model and the terrain height value of the second terrain model.
2. The method according to claim 1, characterized in that, creating a first terrain model and a second terrain model on a planar geometric body includes: building a basic model set on the planar geometric body; grouping the basic model set into the first terrain model and the second terrain model; storing the first terrain model in a first tool node and storing the second terrain model in a second tool node, wherein the first tool node is used to export the terrain model to be excavated, and the second tool node is used to export the terrain model to be elevated.
3. The method according to claim 1, characterized in that, creating a first terrain model and a second terrain model on a planar geometric body includes: responding to a drag instruction of a curve tool, drawing a curve on the planar geometric body to generate a terrain trend line, wherein the terrain trend line is used to indicate the scatter point range of the terrain model to be generated; obtaining scatter point parameters of the terrain trend line, wherein the scatter point parameters include at least one of the following: a ramp curve graph of the scatter point range, the number of models, and a model scaling parameter; generating the first terrain model and the second terrain model on the planar geometric body by using the scatter point parameters.
4. The method according to claim 1, characterized in that, Baking the terrain detail parameters of the scene terrain locally in the modeling engine based on the terrain file, and generating the terrain layer data of the scene terrain includes: Generating the basic terrain data of the scene terrain locally in the modeling engine using the terrain file; Performing terrain distortion on the basic terrain locally in the modeling engine to generate the first detailed terrain; Performing surface erosion on the first detailed terrain locally in the modeling engine to generate the second detailed terrain; Allocating texture maps for the second detailed terrain locally in the modeling engine to generate the terrain layer data of the scene terrain.
5. The method according to claim 4, wherein, Performing terrain distortion on the basic terrain locally in the modeling engine includes: Performing blurring on the basic terrain locally in the modeling engine to obtain a first intermediate model; Dividing the first intermediate model into a first geometric body and a second geometric body; Performing distortion processing and noise processing on the first geometric body in sequence, and performing custom modification on the second geometric body.
6. The method according to claim 4, wherein, Performing surface erosion on the first detailed terrain locally in the modeling engine includes: Determining the first geometric body and the second geometric body in the first detailed terrain, wherein the second geometric body corresponds to the terrain area with custom modification; Generating an erosion protection mask on the second geometric body; Obtaining preset erosion parameters, and performing erosion processing on the surface layer of the first detailed terrain using the erosion parameters.
7. The method according to claim 4, wherein, Allocating texture maps for the second detailed terrain locally in the modeling engine includes: Responding to the operation instruction of the curve tool locally in the modeling engine, and delineating a number of target areas in the second detailed terrain, wherein each target area corresponds to the geomorphic range of a geomorphic type; For each target area, searching for a texture map that matches the geomorphic type of the target area; Baking the texture map in the target area.
8. A device for generating a scene terrain, wherein, comprises: A creation module, configured to create a first terrain model and a second terrain model on a planar geometric body; A processing module, configured to dig down the first terrain model and raise the second terrain model on the planar geometric body to generate a terrain file of the scene terrain; A generation module, configured to import the terrain file into a modeling engine, and bake the terrain detail parameters of the scene terrain locally in the modeling engine based on the terrain file to generate the terrain layer data of the scene terrain; Wherein, the processing module includes: a determining unit, configured to determine the lowest surface value of the first terrain model and the highest surface value of the second terrain model; a reading unit, configured to read a first set of initial terrain voxels of the first terrain model and a second set of initial terrain voxels of the second terrain model; a processing unit, configured to merge each terrain voxel in the first set of initial terrain voxels based on the maximum value of the longitudinal coordinate according to the lowest surface value to obtain a first set of intermediate terrain voxels, and merge each terrain voxel in the first set of intermediate terrain voxels based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the first terrain model; merge each terrain voxel in the second set of initial terrain voxels based on the maximum value of the longitudinal coordinate according to the highest surface value to obtain a second set of intermediate terrain voxels, and merge each terrain voxel in the second set of intermediate terrain voxels based on the minimum value of the longitudinal coordinate to obtain the terrain height value of the second terrain model; a generating unit, configured to generate a terrain file of the scene terrain based on the terrain height value of the first terrain model and the terrain height value of the second terrain model.
9. A storage medium, characterized in that a computer program is stored in the storage medium, wherein the computer program is configured to execute the method described in any one of claims 1 to 7 when running.
10. An electronic device, comprising a memory and a processor, characterized in that a computer program is stored in the memory, and the processor is configured to run the computer program to execute the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Game scene construction method and device, computer storage medium and electronic device
CN110262865A
Virtual terrain processing method and device, electronic equipment and storage medium
CN111524231A