Game terrain processing method and device, electronic equipment and storage medium
By synchronously modifying the height data and texture weight data of the target terrain and the basic terrain, the problems of high cost and low efficiency of terrain editing are solved, and efficient terrain editing and multi-platform compatible role interaction are achieved.
Patent Information
- Application Number
- CN202411288184.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-01-10
AI Technical Summary
In the prior art, the cost of editing and maintenance of terrain is high and the editing efficiency is low, especially in seasonal transformation and terrain interaction scenarios.
By receiving editing requests, synchronous modification of the target terrain and basic terrain, adjust the height data and texture weight data, generate the edited target terrain, realize automatic synchronous modification of the target terrain and basic terrain, reduce the cost of terrain editing and maintenance, and improve editing efficiency.
Automatic synchronous modification of target terrain and basic terrain is achieved, reducing terrain editing and maintenance costs, improving editing efficiency, and supporting high-quality real-time rendering and multi-platform compatible role interaction.
Smart Images

Figure CN119280829A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for processing game terrain. Background Art
[0002] In video game scenes, high-quality and efficient terrain rendering has always been a difficult technical problem. Terrain usually uses a height map to express its geometry, and each pixel value of the height map represents the corresponding height of the terrain in three-dimensional space. The texture of the terrain is usually mixed by multiple layers, which are tiled on the entire terrain, and the mixing ratio of each layer is determined according to a weight map to finally form the terrain texture.
[0003] Seasonal changes are an important means for video games to increase realism and enhance player immersion. However, the physical performance caused by seasonal changes (for example, the volumetric performance of snow in winter) and the interaction between player characters and terrain pose great technical challenges. As the largest scene element, the terrain scheme (for example, the snow cover scheme) has also become a key factor in determining the final game performance.
[0004] From the perspective of terrain production, each time the related technology modifies the basic terrain, it is necessary to make corresponding modifications to the target terrain (for example, snow-covered terrain), thereby increasing the terrain editing cost and maintenance cost and reducing the terrain editing efficiency. Summary of the invention
[0005] The present disclosure provides a method, device, electronic device and storage medium for processing game terrain, so as to at least solve the problems of high terrain editing and maintenance costs and low editing efficiency in related technologies. The technical solution of the present disclosure is as follows:
[0006] According to a first aspect of an embodiment of the present disclosure, a method for processing game terrain is provided, comprising:
[0007] receiving a first editing request sent by a first account; the first editing request is used to request synchronous modification of a target terrain and a basic terrain, wherein the target terrain is overlaid on the basic terrain;
[0008] In response to the first editing request, the initial height data of the base terrain is adjusted to obtain first height data, and the initial height data of the target terrain is synchronously modified in a manner corresponding to the modification of the initial height data of the base terrain to obtain second height data corresponding to the target terrain; wherein the difference between the first height data and the initial height data of the base terrain is equal to the difference between the second height data and the initial height data of the target terrain;
[0009] Adjusting the initial texture weight data of the base terrain to obtain first texture weight data, and fusing the first texture weight data with the initial texture weight data of the target terrain to obtain second texture weight data corresponding to the target terrain;
[0010] The edited target terrain is generated according to the second height data corresponding to the target terrain and the second texture weight data corresponding to the target terrain.
[0011] In an optional embodiment, in response to the first editing request, adjusting the initial height data of the basic terrain to obtain the first height data includes:
[0012] In response to the first editing request, increasing or decreasing the initial height data of the basic terrain by a preset height to obtain the first height data;
[0013] The performing synchronous modification on the initial height data of the target terrain in a manner corresponding to the modification of the initial height data of the base terrain to obtain second height data corresponding to the target terrain includes:
[0014] In the case where a preset height is added to the initial height data of the base terrain, the preset height is added to the initial height data of the target terrain to obtain second height data;
[0015] In the case where the initial height data of the basic terrain is reduced by the preset height, the initial height data of the target terrain is reduced by the preset height to obtain second height data.
[0016] In an optional embodiment, the basic terrain includes a preset number of layers, the initial texture weight data of the basic terrain is adjusted to obtain the first texture weight data, and the initial height data of the target terrain is synchronously modified corresponding to the modification method of the initial height data of the basic terrain to obtain the second height data corresponding to the target terrain, including:
[0017] Adjusting the initial texture weight data corresponding to each of the preset number of layers to obtain adjusted texture weight data corresponding to each of the preset number of layers;
[0018] Generate the first texture weight data according to the adjusted texture weight data corresponding to each of the preset number of layers;
[0019] Adding the adjusted texture weight data corresponding to each of the preset number of layers to obtain weight fusion data;
[0020] The initial texture weight data of the target terrain is fused according to the weight fusion data to obtain second texture weight data corresponding to the target terrain; wherein the sum of the second texture weight data and the weight fusion data is 1.
[0021] In an optional embodiment, the method further includes:
[0022] receiving a second editing request sent by the first account, wherein the second editing request is used to request modification of the target terrain;
[0023] In response to the second editing request, modify the initial height data and the initial texture weight data of the target terrain to obtain third height data and third texture weight data corresponding to the target terrain;
[0024] The edited target terrain is generated according to the third height data and the third texture weight data corresponding to the target terrain.
[0025] In an optional embodiment, the modifying the initial height data and the initial texture weight data of the target terrain to obtain the third height data and the third texture weight data corresponding to the target terrain includes:
[0026] Obtaining a preset mask map; the preset mask map is used to control the display or hiding of the target terrain;
[0027] Covering the preset mask map on the target terrain;
[0028] In response to the parameter adjustment instruction for the preset mask map, the texture weight data of the target terrain is adjusted to control display or hiding of the target terrain, and third texture weight data corresponding to the target terrain is obtained;
[0029] A preset terrain thickness parameter is obtained, and the initial height data of the target terrain is modified based on the preset terrain thickness parameter to obtain third height data corresponding to the target terrain.
[0030] In an optional embodiment, after generating the edited target terrain, the method further includes:
[0031] During the process of running the game application by the second account, determining whether the edited target terrain has been deformed;
[0032] When it is determined that the edited target terrain is deformed, obtaining a position of a virtual object in the game, motion deformation data corresponding to the virtual object, and a preset brush map;
[0033] Generating height change data according to the preset brush map, the position of the virtual object and the motion deformation data;
[0034] Performing normal vector change analysis on the height change data to obtain normal direction change data;
[0035] The geometric data of the edited target terrain is modified according to the height change data and the normal change data to render the edited target terrain.
[0036] In an optional embodiment, performing normal vector change analysis processing on the height change data to obtain normal change data includes:
[0037] According to the height change data, obtaining the terrain vertex at the deformation position in the edited target terrain;
[0038] Determine the gradient of the vertex position corresponding to the terrain vertex at the deformation position;
[0039] generating a vertex normal vector based on the gradient of the vertex position;
[0040] The normal change data is generated according to the difference between the vertex normal vector and the initial vertex normal vector; the initial vertex normal vector is the vertex normal vector of the terrain vertex at the deformation position before the deformation.
[0041] In an optional embodiment, modifying the geometric data of the edited target terrain according to the height change data and the normal change data to render the edited target terrain includes:
[0042] According to the game running platform, the height change data is modified in the pixel shader using parallax mapping technology or surface subdivision technology, and in the pixel shader, the normal vector of the pixel in the edited target terrain is modified according to the normal change map to render the generated edited target terrain.
[0043] In an optional embodiment, the modifying the height change data using a parallax mapping technique or a tessellation technique in a pixel shader includes:
[0044] In a case where the device logged in by the second account is a mobile platform, applying the height change data to parallax mapping in a pixel shader to offset texture coordinates of the edited target terrain;
[0045] When the device logged in by the second account is a personal computer or a game console platform, the mesh of the deformed position in the edited target terrain is refined based on the surface subdivision technology in the pixel shader, and the height of the edited target terrain is adjusted according to the height change data.
[0046] In an optional embodiment, after generating the edited target terrain, the method further includes:
[0047] During the process of running the game application by the second account, determining whether the edited target terrain has been deformed;
[0048] When it is determined that there is no deformation of the edited target terrain, the second height data corresponding to the edited target terrain is converted into mesh data, and each layer in the edited target terrain is mixed according to the second texture weight data and the mesh data to render the edited target terrain.
[0049] In an optional embodiment, the target terrain includes at least one of snow terrain, desert terrain, and wetland terrain.
[0050] According to a second aspect of an embodiment of the present disclosure, a game terrain processing device is provided, the device comprising:
[0051] A first editing request sending module is configured to execute and receive a first editing request sent by a first account; the first editing request is used to request synchronous modification of the target terrain and the basic terrain, and the target terrain is covered on the basic terrain;
[0052] A first height data generating module is configured to, in response to the first editing request, adjust the initial height data of the base terrain to obtain first height data, and perform synchronous modification on the initial height data of the target terrain corresponding to the modification method of the initial height data of the base terrain to obtain second height data corresponding to the target terrain; wherein the difference between the first height data and the initial height data of the base terrain is equal to the difference between the second height data and the initial height data of the target terrain;
[0053] a texture weight data generating module, configured to adjust the initial texture weight data of the base terrain to obtain first texture weight data, and fuse the first texture weight data with the initial texture weight data of the target terrain to obtain second texture weight data corresponding to the target terrain;
[0054] The terrain generation module is configured to generate an edited target terrain according to the second height data corresponding to the target terrain and the second texture weight data corresponding to the target terrain.
[0055] In an optional embodiment, the first height data generating module includes:
[0056] A first edit request response unit is configured to increase or decrease the initial height data of the basic terrain by a preset height in response to the first edit request to obtain the first height data;
[0057] A synchronous modification unit is configured to perform synchronous modification on the initial height data of the target terrain corresponding to the modification method of the initial height data of the base terrain to obtain second height data corresponding to the target terrain, including:
[0058] a height increasing unit configured to increase the preset height to the initial height data of the target terrain by the preset height to obtain second height data;
[0059] The height reduction unit is configured to reduce the initial height data of the target terrain by the preset height when the initial height data of the base terrain is reduced by the preset height to obtain second height data.
[0060] In an optional embodiment, the texture weight data generating module includes:
[0061] A first texture adjustment unit is configured to adjust the initial texture weight data corresponding to each of the preset number of layers to obtain adjusted texture weight data corresponding to each of the preset number of layers;
[0062] A second texture adjustment unit is configured to generate the first texture weight data according to the adjusted texture weight data corresponding to each of the preset number of layers;
[0063] A weight adding unit is configured to add the adjusted texture weight data corresponding to each of the preset number of layers to obtain weight fusion data;
[0064] The weight fusion unit is configured to perform fusion processing on the initial texture weight data of the target terrain according to the weight fusion data to obtain second texture weight data corresponding to the target terrain; wherein the sum of the second texture weight data and the weight fusion data is 1.
[0065] In an optional embodiment, the device further comprises:
[0066] A second editing request receiving unit is configured to receive a second editing request sent by the first account; the second editing request is used to request modification of the target terrain;
[0067] a second edit request response unit, configured to modify the initial height data and the initial texture weight data of the target terrain in response to the second edit request, so as to obtain third height data and third texture weight data corresponding to the target terrain;
[0068] The edited target terrain determining unit is configured to generate the edited target terrain according to the third height data and the third texture weight data corresponding to the target terrain.
[0069] In an optional embodiment, the second edit request response unit includes:
[0070] A preset mask map acquisition subunit is configured to acquire a preset mask map; the preset mask map is used to control the display or hiding of the target terrain;
[0071] A covering subunit, configured to cover the preset mask map on the target terrain;
[0072] A third texture weight data generating subunit is configured to execute, in response to a parameter adjustment instruction for the preset mask map, to adjust the texture weight data of the target terrain to control display or hiding of the target terrain, and obtain third texture weight data corresponding to the target terrain;
[0073] The third height data generating subunit is configured to obtain a preset terrain thickness parameter, modify the initial height data of the target terrain based on the preset terrain thickness parameter, and obtain third height data corresponding to the target terrain.
[0074] In an optional embodiment, the device further comprises:
[0075] A first deformation determination module is configured to determine whether the edited target terrain has deformation during the process of the second account running the game application;
[0076] An information acquisition module is configured to acquire, when it is determined that the edited target terrain is deformed, a position of a virtual object in the game, motion deformation data corresponding to the virtual object, and a preset brush map;
[0077] A height change data generating module is configured to generate height change data according to the preset brush map, the position of the virtual object and the motion deformation data;
[0078] A normal change data generating module is configured to perform normal vector change analysis processing on the height change data to obtain normal change data;
[0079] The first rendering module is configured to modify the geometric data of the edited target terrain according to the height change data and the normal change data, so as to render the edited target terrain.
[0080] In an optional embodiment, the normal change data generating module includes:
[0081] A terrain vertex acquisition unit, configured to acquire terrain vertices at deformation positions in the edited target terrain according to the height change data;
[0082] A gradient determination unit, configured to determine the gradient of the vertex position corresponding to the terrain vertex at the deformation position;
[0083] A vertex normal vector generation unit, configured to generate a vertex normal vector based on a gradient of the vertex position;
[0084] The difference processing unit is configured to generate the normal change data according to the difference between the vertex normal vector and the initial vertex normal vector; the initial vertex normal vector is the vertex normal vector of the terrain vertex at the deformation position before the deformation.
[0085] In an optional embodiment, the rendering module includes:
[0086] A modified rendering unit is configured to execute, according to the game running platform, a parallax mapping technology or a surface subdivision technology to modify the height change data in a pixel shader, and in the pixel shader, according to the normal change map, modify the normal vector of the pixel in the edited target terrain to render the generated edited target terrain.
[0087] In an optional embodiment, the modifying rendering unit includes:
[0088] an offset subunit configured to apply the height change data to a parallax map in a pixel shader to offset the texture coordinates of the edited target terrain when the device logged in by the second account is a mobile platform;
[0089] The refinement subunit is configured to execute, when the device logged in by the second account is a personal computer or a game console platform, to refine the mesh of the deformed position in the edited target terrain based on the surface subdivision technology in the pixel shader, and adjust the height of the edited target terrain according to the height change data.
[0090] In an optional embodiment, the device further comprises:
[0091] A second deformation determination module is configured to determine whether the edited target terrain has deformation during the process of the second account running the game application;
[0092] The second rendering module is configured to convert the second height data corresponding to the edited target terrain into mesh data when it is determined that the edited target terrain does not have any deformation, and mix the various layers in the edited target terrain according to the second texture weight data and the mesh data to render the edited target terrain.
[0093] In an optional embodiment, the target terrain includes at least one of snow terrain, desert terrain, and wetland terrain.
[0094] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device for processing game terrain, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the game terrain processing method as described above.
[0095] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to execute the game terrain processing method as described above.
[0096] According to the fifth aspect of an embodiment of the present disclosure, a computer program product is provided, which includes a computer program, and the computer program is stored in a readable storage medium. At least one processor of a computer device reads and executes the computer program from the readable storage medium, so that the device executes the above-mentioned game terrain processing method.
[0097] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0098] The present invention responds to a first editing request for synchronously modifying the target terrain and the base terrain, automatically performs synchronous modification on the initial height data of the target terrain corresponding to the modification method of the initial height data of the base terrain, fuses the initial texture weight data of the target terrain with the adjusted first texture weight data corresponding to the base terrain, and obtains the second texture weight data corresponding to the target terrain. This can associate the coupling relationship between the base terrain and the snow-covered terrain, take the target terrain as an increment of the base terrain, and realize automatic synchronous modification of the target terrain and the base terrain without having to make corresponding modifications to the target terrain again after each modification of the base terrain, thereby reducing the terrain editing cost and maintenance cost and improving the terrain editing efficiency.
[0099] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0100] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0101] Figure 1 It is a schematic diagram of an application environment of a method for processing game terrain according to an exemplary embodiment.
[0102] Figure 2 The following is a flow chart of a method for processing game terrain according to an exemplary embodiment. Figure 1 .
[0103] Figure 3 A process for rendering terrain according to an exemplary embodiment is shown Figure 1 .
[0104] Figure 4 A process for rendering terrain according to an exemplary embodiment is shown Figure 2 .
[0105] Figure 5 It is a schematic diagram showing a height variation diagram according to an exemplary embodiment.
[0106] Figure 6 is a schematic diagram of a normal change diagram according to an exemplary embodiment.
[0107] Figure 7 A process for rendering terrain according to an exemplary embodiment is shown Figure 3 .
[0108] Figure 8 The diagram is a schematic diagram showing a method of offsetting texture coordinates according to parallax mapping according to an exemplary embodiment.
[0109] Fig. 9 The figure is a schematic diagram showing a method of refining the mesh accuracy of a deformation area according to a surface subdivision function according to an exemplary embodiment.
[0110] Fig.10 The figure is a block diagram of a game terrain processing device according to an exemplary embodiment.
[0111] Fig.11 The invention is a block diagram of an electronic device for processing game terrain according to an exemplary embodiment. DETAILED DESCRIPTION
[0112] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0113] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar first objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0114] The Unity engine is one of the more popular game engines currently. It has a relatively complete terrain solution built in, including editing of terrain height maps and weight maps, configuration of terrain texture layers, and final meshing and rendering.
[0115] For the development and editing of the scene's basic terrain, the functions provided by the Unity engine can basically meet the needs. However, the base terrain and the target terrain (for example, snow-covered terrain) require two sets of height maps and weight maps, and the editing of the target terrain needs to rely on the base terrain (such as the height of the snow-covered terrain must be greater than the base terrain, and the area with less snow coverage needs to show the texture of the base terrain, etc.), and it also needs to be able to switch at runtime. The lack of these functions makes it impossible to develop and edit the target terrain directly on the Unity engine. In addition, the terrain of the Unity engine can only be interactively displayed by modifying the height map at runtime, which not only has a large performance overhead, but also the accuracy is difficult to guarantee, and cannot meet the needs of game development.
[0116] That is, from the perspective of terrain production in the game scene, the terrain is large in size, the editing cost and maintenance cost of editing the terrain by the first account (for example, the account corresponding to the game developer) is high, and the editing efficiency is low; from the performance level, the terrain accounts for a large proportion of the game screen, and the interaction between the second account (for example, the account corresponding to the game player) and the target terrain (for example, snow-covered terrain) requires dynamic modification of the terrain height map while the game is running, thereby modifying the geometry of the target terrain, and this operation has high requirements on the accuracy of the terrain height, making it difficult to balance performance overhead and screen performance.
[0117] Based on this, the present disclosure provides a method, device, electronic device and storage medium for processing game terrain. From the perspective of terrain production in the game scene, the present disclosure can associate the coupling relationship between the basic terrain and the snow-covered terrain, and use the target terrain as an increment of the basic terrain to achieve synchronous modification of the target terrain and the basic terrain, without having to make corresponding modifications to the target terrain after each modification of the basic terrain, thereby reducing the terrain editing cost and maintenance cost and improving the terrain editing efficiency; at the same time, it can also provide a dynamic switching function for the two sets of terrains. From the performance level, high-quality real-time rendering of the target terrain can be achieved, and it can be compatible with the role interaction of various platforms, that is, it can meet the artistic expression and take into account the operating efficiency.
[0118] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0119] See also Figure 1 , Figure 1 is a schematic diagram of an application environment of a method for processing game terrain according to an exemplary embodiment. Figure 1 As shown, the application environment may include a terminal 01 and a server 02 .
[0120] The method for editing game terrain data of the embodiment of the present application can be executed by the server 02, or by the terminal 01, or by both the server 02 and the terminal 01. The terminal 01 can also execute the game terrain processing of the embodiment of the present application by the client installed thereon.
[0121] Exemplarily, terminal 01 may include, but is not limited to, electronic devices such as smart phones, desktop computers, tablet computers, laptops, smart speakers, digital assistants, augmented reality (AR) / virtual reality (VR) devices, and smart wearable devices.
[0122] Exemplarily, the server 02 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0123] In addition, it should be noted that Figure 1What is shown is only one application environment of the game terrain processing method provided by the present disclosure. In other scenarios, there may be other application environments, which are not limited by the present disclosure.
[0124] Figure 2 The following is a flow chart of a method for processing game terrain according to an exemplary embodiment. Figure 1 ,like Figure 2 As shown, the method comprises at least the following steps:
[0125] In step S11, a first editing request sent by a first account is received; the first editing request is used to request synchronous modification of the target terrain and the basic terrain, and the target terrain is overlaid on the basic terrain.
[0126] Optionally, the first account may be an account corresponding to a game developer.
[0127] Optionally, the base terrain is an existing terrain in the game scene. The target terrain is a terrain covered on the base terrain, for example, the target terrain includes at least one of snow terrain, desert terrain, and wetland terrain. The technical solution disclosed in the present invention can realize efficient and low-cost editing of snow terrain, desert terrain, wetland terrain and other terrains together with the base terrain. In addition, high-quality real-time rendering of snow terrain, desert terrain, wetland terrain and other terrains can be achieved, and it can be compatible with character interactions on various platforms, that is, it can meet the needs of artistic expression and take into account operational efficiency.
[0128] Optionally, the coupling relationship between the base terrain and the target terrain can be pre-associated so that when the base terrain is modified, the target terrain is modified synchronously. When the first account wants to modify the target terrain, a first editing request for synchronously modifying the target terrain and the base terrain can be triggered.
[0129] It should be noted that the first editing request may carry modification parameters for synchronously modifying the target terrain and the basic terrain.
[0130] In step S13, in response to the first editing request, the initial height data of the base terrain is adjusted to obtain first height data, and the initial height data of the target terrain is synchronously modified in a manner corresponding to the modification method of the initial height data of the base terrain to obtain second height data corresponding to the target terrain; wherein the difference between the first height data and the initial height data of the base terrain is equal to the difference between the second height data and the initial height data of the target terrain.
[0131] In step S15, the initial texture weight data of the base terrain is adjusted to obtain first texture weight data, and the first texture weight data and the initial texture weight data of the target terrain are fused to obtain second texture weight data corresponding to the target terrain.
[0132] In step S17, the edited target terrain is generated according to the second height data corresponding to the target terrain and the second texture weight data corresponding to the target terrain.
[0133] Optionally, after receiving the first editing request, the base terrain and the target terrain may be modified synchronously. The first editing request may carry modification parameters for modifying the height data and modification parameters for modifying the texture weight data.
[0134] For height data, after adjusting the initial height data of the base terrain to obtain the first height data, the target terrain can be used as an increment of the base terrain based on the coupling relationship between the pre-associated base terrain and the target terrain, and the initial height data of the target terrain can be synchronously modified in accordance with the modification method of the initial height data of the base terrain to obtain the second height data corresponding to the target terrain. The difference between the first height data and the initial height data of the base terrain is equal to the difference between the second height data and the initial height data of the target terrain. For example, the initial height data of the base terrain is h1, the first height data is h2, the initial height data of the target terrain is h3, and the second height data is h4, then the difference between h2 and h1 is equal to the difference between h4 and h3.
[0135] It should be noted that the initial height of the target terrain can be 0, that is, before the terrain is edited, the base terrain has not been covered by the target terrain, then a target terrain can be generated on the base terrain based on the coupling relationship between the pre-associated base terrain and the target terrain, and the second height data of the target terrain is equal to the difference between the first height data and the initial height data of the base terrain. In the case where the initial height of the target terrain is not 0, that is, before the terrain is edited, the base terrain has been covered by the target terrain, then the initial height data corresponding to the target terrain can be adjusted based on the coupling relationship between the pre-associated base terrain and the target terrain and the difference between the first height data and the initial height data of the base terrain.
[0136] For texture weight data, after adjusting the initial texture weight data of the base terrain to obtain the first texture weight data, based on the coupling relationship between the pre-associated base terrain and the target terrain, the target terrain can be used as an increment of the base terrain, and the initial texture weight data of the target terrain and the adjusted first texture weight data corresponding to the base terrain can be fused to obtain the second texture weight data corresponding to the target terrain.
[0137] Optionally, after obtaining the second height data and the second texture weight data corresponding to the target terrain, the edited target terrain may be generated based on the second height data and the second texture weight data corresponding to the target terrain.
[0138] It should be noted that the height data may refer to the height map of the terrain, and each pixel value of the height map represents the corresponding height of the terrain in three-dimensional space. The texture weight data may refer to the texture weight map, which determines the relative importance of these textures in the final rendering result by assigning a weight value to each layer of texture, which determines the contribution ratio of each layer of terrain texture to the final terrain color.
[0139] Therefore, the present invention can associate the coupling relationship between the basic terrain and the snow-covered terrain, take the target terrain as an increment of the basic terrain, and realize the synchronous modification of the target terrain and the basic terrain, without making corresponding modifications to the target terrain every time the basic terrain is modified, thereby reducing the terrain editing cost and maintenance cost and improving the terrain editing efficiency.
[0140] In an optional embodiment, in the above step S13, in response to the first editing request, adjusting the initial height data of the basic terrain to obtain the first height data includes:
[0141] In response to the first editing request, the initial height data of the basic terrain is increased or decreased by a preset height to obtain the first height data.
[0142] Correspondingly, in the above steps, performing synchronous modification on the initial height data of the target terrain corresponding to the modification method of the initial height data of the base terrain to obtain second height data corresponding to the target terrain includes:
[0143] In the case where the preset height is added to the initial height data of the basic terrain, the preset height is added to the initial height data of the target terrain to obtain second height data.
[0144] In the case where the initial height data of the basic terrain is reduced by the preset height, the initial height data of the target terrain is reduced by the preset height to obtain second height data.
[0145] In this embodiment, the modification of the initial height of the basic terrain may include an increase in height or a decrease in height. In one embodiment, when the initial height data of the basic terrain is increased by a preset height, the initial height data of the target terrain may also be automatically increased by a preset height to obtain second height data. In another embodiment, when the initial height data of the basic terrain is reduced by a preset height, the initial height data of the target terrain may also be automatically reduced by a preset height to obtain second height data. Thus, the target terrain can be used as an increment of the basic terrain to achieve synchronous modification of the height data of the target terrain and the basic terrain, without having to make corresponding modifications to the height data of the target terrain each time the height data of the basic terrain is modified, thereby reducing the editing cost and maintenance cost of the height data of the terrain and improving the editing efficiency of the height data of the terrain.
[0146] In an optional embodiment, in the above step S15, the above base terrain includes a preset number of layers, the adjusting the initial texture weight data of the base terrain to obtain the first texture weight data, and fusing the first texture weight data with the initial texture weight data of the target terrain to obtain the second texture weight data corresponding to the target terrain may include:
[0147] The initial texture weight data corresponding to each of the preset number of layers is adjusted to obtain the adjusted texture weight data corresponding to each of the preset number of layers.
[0148] The first texture weight data is generated according to the adjusted texture weight data corresponding to each of the preset number of layers.
[0149] The adjusted texture weight data corresponding to each of the preset number of layers are added together to obtain weight fusion data.
[0150] The initial texture weight data of the target terrain is fused according to the weight fusion data to obtain second texture weight data corresponding to the target terrain; wherein the sum of the second texture weight data and the weight fusion data is 1.
[0151] Optionally, the basic graphics include a preset number of layers. When modifying the texture weight data of the terrain in response to the first editing request, for the basic terrain, the initial weight texture data of each layer in the basic terrain can be adjusted directly according to the adjustment parameters of the weight texture data carried in the first editing request to obtain the adjusted texture weight data corresponding to each of the preset number of layers. Then, the adjusted texture weight data corresponding to each of the preset number of layers can be fused and aggregated to obtain the first texture weight data.
[0152] Since the sum of the weight of the target terrain and the weights of each image in the basic terrain is 1, the adjusted texture weight data corresponding to each of the preset number of layers can be added to obtain weight fusion data, and the difference between 1 and the weight fusion data is calculated, and the initial texture weight data of the target terrain is adjusted to the difference to obtain the second texture weight data corresponding to the target terrain. After the adjustment, the sum of the second texture weight data and the weight fusion data is 1, that is, after the adjustment, the sum of the second texture weight data and the weights of each layer in the basic terrain is 1.
[0153] Taking the target terrain as snow-covered terrain as an example, the above step S15 is explained as follows:
[0154] Before editing the terrain, if the target terrain is not covered on the base terrain, assuming that the base terrain includes four layers, the weight of the base terrain is 1 when there is no snow-covered terrain, and the weight of each of the four layers is 0.25. When the snow-covered terrain is covered on the base terrain, since the sum of the weights of the base terrain and the snow-covered terrain is 1, if the weight of the base terrain is adjusted to 0.5, the weight of the snow-covered terrain is also 0.5. At this time, the weights of the four layers in the base terrain are all 0.125.
[0155] Before editing the terrain, when the target terrain is already covered on the base terrain, and the weight of the base terrain is 0.5, and the weight of the snow-covered terrain is also 0.5, if the first editing request requests that the weights of the four layers of the base terrain be adjusted to 0.1, the weight fusion data of the base terrain is 0.4. At this time, the initial texture weight data of the target terrain can be fused according to the weight fusion data to obtain the second texture weight data corresponding to the target terrain, so that the second texture weight data is adjusted from 0.5 to 0.6, so that the sum of the second texture weight data and the weight fusion data is 1.
[0156] In this way, the target terrain can be used as an increment of the basic terrain to achieve synchronous modification of the target terrain and the basic terrain, without having to make corresponding modifications to the texture weight data of the target terrain every time the texture weight data of the basic terrain is modified, thereby reducing the editing cost and maintenance cost of the texture weight data of the terrain and improving the terrain editing efficiency; in addition, since the texture weight data of each layer in the basic terrain can accurately reflect the texture weight data of the basic terrain, the initial texture weight data of the target terrain is fused based on the texture weight data of each layer in the basic terrain, which can improve the adjustment accuracy of the texture weight data corresponding to the target terrain.
[0157] It should be noted that the editing of the target terrain will not affect the editing of any basic terrain. Accordingly, the above method may also include:
[0158] A second editing request sent by the first account is received; the second editing request is used to request modification of the target terrain.
[0159] In response to the second editing request, the initial height data and the initial texture weight data of the target terrain are modified to obtain third height data and third texture weight data corresponding to the target terrain.
[0160] The edited target terrain is generated according to the third height data and the third texture weight data corresponding to the target terrain.
[0161] Optionally, when the first account wants to modify the height data and initial texture weight data of the target terrain, a second edit request can be triggered, and the second edit request can carry modification parameters for modifying the height data and initial texture weight data of the target terrain. The initial height data and initial texture weight data of the target terrain are modified according to the modification parameters to obtain the third height data and third texture weight data corresponding to the target terrain, and finally the edited target terrain is generated according to the third height data and third texture weight data corresponding to the target terrain. In this way, the editing of the target terrain will not respond to any data of the basic terrain, ensuring the integrity of the basic terrain, reducing the cost of terrain editing, and improving the accuracy of terrain editing.
[0162] In an optional embodiment, in order to further improve the editing efficiency of the target terrain, the present disclosure also provides a programmatic generation function. The programmatic generation function may include but is not limited to: modifying the weight of the snow map layer according to the mask map, and supporting avoiding other obstacles (such as roads) in the scene when covering the snow; automatically modifying the height map of the snow-covered terrain according to the configured preset terrain thickness parameters (for example, snow thickness parameters), etc.
[0163] Accordingly, the initial height data and initial texture weight data of the target terrain are modified to obtain third height data and third texture weight data corresponding to the target terrain, including:
[0164] Obtain a preset mask map; the preset mask map is used to control the display or hiding of the target terrain.
[0165] The preset mask map is covered on the target terrain.
[0166] In response to the parameter adjustment instruction for the preset mask map, the texture weight data of the target terrain is adjusted to control the display or hiding of the target terrain, and the third texture weight data corresponding to the target terrain is obtained.
[0167] A preset terrain thickness parameter is obtained, and the initial height data of the target terrain is modified based on the preset terrain thickness parameter to obtain third height data corresponding to the target terrain.
[0168] Optionally, a preset terrain thickness parameter and a preset mask map may be first obtained. The preset mask map is used to control the display or hiding of the target terrain. The production of the preset mask map may be completed by image processing software. Taking the target terrain as a snow-covered terrain as an example, in the preset mask map, the part to be displayed may be set to white, and the part to be hidden may be set to black. By adjusting the mask map, it is possible to accurately control which areas on the base terrain should display the snow effect.
[0169] Next, the preset mask map is overlaid on the target terrain to be applied to the target terrain. Furthermore, the preset mask map can be imported into the relevant settings in the target terrain.
[0170] Then, the texture weight data of the target terrain can be adjusted in response to the parameter adjustment instructions of the preset mask map. Taking the target terrain as snow-covered terrain as an example, the white area in the preset mask map will increase the weight of the snow-covered terrain, while the black area will reduce or remove the display of the snow-covered terrain, thereby controlling the display or hiding of the snow-covered terrain. That is, the procedural function can be used to generate a snow-covered terrain version first, and then make some fine-tuning and refinement on this basis to further improve the efficiency of terrain editing.
[0171] Optionally, for the height data, the initial height data of the target terrain may be modified directly according to the preset thickness parameter to obtain third height data corresponding to the target terrain.
[0172] Therefore, according to the programmatically generated functions, the texture weight data and height data of the target terrain can be accurately adjusted according to the specific requirements of the game scene, effectively improving the editing efficiency of the texture weight data and height data of the target terrain.
[0173] After generating the edited target terrain, the present disclosure may also render the edited target terrain. Figure 3 A process for rendering terrain according to an exemplary embodiment is shown Figure 1 ,like Figure 3 As shown, in an optional embodiment, after generating the edited target terrain, the method further includes:
[0174] In step S21, during the process of the second account running the game application, it is determined whether the edited target terrain is deformed.
[0175] In step S23, when it is determined that the edited target terrain does not have any deformation, the second height data corresponding to the edited target terrain is converted into mesh data, and each layer in the edited target terrain is mixed according to the second texture weight data and the mesh data to render the edited target terrain.
[0176] Optionally, the second account may be an account for running the game application, for example, a player account. During the process of the second account running the game application, it may be determined whether the edited target terrain is deformed. Exemplarily, it may be determined whether the edited target terrain is deformed by whether the target terrain interacts with a game character in the game application. If the target terrain interacts with the game character in the game application, it is determined that the edited target terrain is deformed; if the target terrain does not interact with the game character in the game application, it is determined that the edited target terrain is not deformed.
[0177] Optionally, when there is no deformation in the edited target terrain, the rendering of the snow-covered terrain is similar to the rendering process of the base terrain. The second height data corresponding to the edited target terrain can be converted into mesh data, that is, the two-dimensional height information is converted into a three-dimensional mesh model to ensure that the height change of the terrain is correctly represented. Then, in the shader, the various layers in the edited target terrain are mixed according to the second texture weight data and the mesh data. This process mainly involves using the second texture weight data to control the degree of influence of different layers. Finally, the vertex shader is responsible for processing the input vertex data, performing coordinate transformation and vertex coloring, and the fragment shader is responsible for generating pixel colors according to the vertex data. In this process, the vertex shader converts the mesh data into standardized device coordinates. At the same time, the fragment shader mixes different layers according to the second texture weight data and the height information to generate the final visual effect, thereby completing the rendering process of the edited target terrain.
[0178] As a result, when the edited target terrain does not deform, the height data can be directly converted into mesh data in advance, and then the layers can be mixed in the shader according to the weight map, thereby reducing the rendering cost and rendering complexity of the target terrain that does not deform, and improving the rendering efficiency of the target terrain that does not deform.
[0179] In an optional embodiment, when the target terrain interacts with a game character in a game application, it is determined that the edited target terrain is deformed. For the deformed target terrain, this can be achieved in two steps: the first step is to determine the terrain deformation, and the second step is to modify the terrain geometry data. Figure 4 A process for rendering terrain according to an exemplary embodiment is shown Figure 2 ,like Figure 4 As shown, after generating the edited target terrain, the method further includes:
[0180] In step S31, during the process of the second account running the game application, it is determined whether the edited target terrain is deformed.
[0181] In step S33, when it is determined that the edited target terrain is deformed, the position of the virtual object in the game, the motion deformation data corresponding to the virtual object and the preset brush map are obtained.
[0182] In step S35, height change data is generated according to the preset brush map, the position of the virtual object and the motion deformation data.
[0183] In step S37, the height change data is subjected to normal vector change analysis to obtain normal direction change data.
[0184] In step S39, the geometric data of the edited target terrain is modified according to the height change data and the normal change data, so as to render the edited target terrain.
[0185] In this embodiment, when it is determined that the edited target terrain is deformed, the terrain deformation may be determined first, and the terrain deformation may be reflected by height change data and normal change data.
[0186] In one embodiment, for the height change data, a map can be used to represent the height deformation degree of an area. For example, the position of a virtual object in the game, the motion deformation data corresponding to the virtual object and the preset brush map can be obtained. The motion deformation data may include but is not limited to: parameters such as the depth and width of the tread mark. Then, according to the preset brush map, the height change data is formed in combination with the parameters such as the depth and width of the tread mark. The height change data can be represented by a height change map. Figure 5is a schematic diagram of a height change diagram according to an exemplary embodiment. In other embodiments, it is also possible to take a picture from the bottom of the scene upwards, and take a picture of the bottom of the object affected by the deformation, so as to determine which areas are deformed and the depth of the deformation. In other embodiments, it is also possible to perform ray detection or collision detection of the terrain to determine the height change data. In other embodiments, it is also possible to use a fixed brush to modify the degree of deformation.
[0187] After determining the height change data, it is also necessary to calculate the normal change. Specifically, after determining the height change data, the normal vector change of the height change data can be analyzed and processed to obtain the normal change data. For example, the normal change data can be represented by a normal change graph. Figure 6 is a schematic diagram of a normal change diagram according to an exemplary embodiment.
[0188] Figure 7 A process for rendering terrain according to an exemplary embodiment is shown Figure 3 ,like Figure 7 As shown, in an exemplary embodiment, in the above step S37, the above-mentioned normal vector change analysis processing is performed on the height change data to obtain the normal change data, which may include:
[0189] In step S371, the terrain vertices at the positions where deformation occurs in the edited target terrain are obtained according to the height change data.
[0190] In step S373, the gradient of the vertex position corresponding to the terrain vertex at the deformation position is determined.
[0191] In step S375, a vertex normal vector is generated based on the gradient of the vertex position.
[0192] In step S377, the normal change data is generated according to the difference between the vertex normal vector and the initial vertex normal vector; the initial vertex normal vector is the vertex normal vector of the terrain vertex at the deformation position before the deformation.
[0193] In this embodiment, after determining to obtain the height change data, the terrain vertex at the position where the deformation occurs in the target terrain after the current deformation occurs can be obtained. And the gradient of the vertex position corresponding to the terrain vertex at the position where the deformation occurs is calculated by the Sobel operator. The gradient calculation process can be specifically as follows: determine the pixel value of the pixel point corresponding to the vertex position, perform a convolution operation with the pixel value by the Sobel operator to obtain the horizontal directional derivative and the vertical directional derivative of the pixel point, and determine the gradient value of the pixel point according to the directional derivative and the vertical directional derivative. Then, generate a vertex normal vector according to the gradient. Finally, compare the vertex normal vector with the initial vertex normal vector of the terrain vertex at the position where the deformation occurs before the deformation to generate the normal change data.
[0194] Therefore, the vertex normal vector can be calculated by gradient calculation according to the terrain vertices at the deformed position in the target terrain, and the normal change data can be generated according to the comparison with the initial vertex normal vector before the deformation occurs, so that the normal vector change data can better reflect the terrain deformation, thereby further improving the rendering accuracy and rendering efficiency of the edited target terrain.
[0195] In this embodiment, after the terrain deformation is determined, the geometric data of the edited target terrain can be modified according to the height change data and the normal change data to render the edited target terrain. In an exemplary embodiment, in the above step S39, the above-mentioned modifying the geometric data of the edited target terrain according to the height change data and the normal change data to render the edited target terrain may include:
[0196] According to the game running platform, the height change data is modified in the pixel shader using parallax mapping technology or surface subdivision technology, and in the pixel shader, the normal vector of the pixel in the edited target terrain is modified according to the normal change map to render the generated edited target terrain.
[0197] Optionally, for height change data, different algorithms can be selected according to the game running platform. Specifically, modifications can be made in the pixel shader according to parallax mapping technology or surface subdivision technology. For changes in terrain normal vectors, the normal vectors of pixels in the edited target terrain can be modified uniformly in the shader according to the normal change map.
[0198] Therefore, for terrain height change data, different algorithms can be selected according to the game running platform. For changes in terrain normal vectors, the normal vectors of pixels can be uniformly modified in the pixel shader according to the normal change map, thereby providing a complete high-quality, high-efficiency target terrain and character interaction pipeline that is compatible with various game platforms, thereby being able to obtain high-quality real-time interactive images of target terrain and characters, and reducing rendering performance overhead.
[0199] In an optional embodiment, the modifying the height change data using a parallax mapping technique or a tessellation technique in a pixel shader includes:
[0200] In the case where the device logged in by the second account is a mobile platform, the height change data is applied to the parallax mapping in the pixel shader to offset the texture coordinates of the edited target terrain.
[0201] When the device logged in by the second account is a personal computer or a game console platform, the mesh of the deformed position in the edited target terrain is refined based on the surface subdivision technology in the pixel shader, and the height of the edited target terrain is adjusted according to the height change data.
[0202] In this embodiment, different algorithms can be selected according to the game running platform. In one way, for mobile platforms, the height change data can be applied to the parallax mapping in the pixel shader to offset the texture coordinates of the edited target terrain. Among them, parallax mapping is a technology in graphics that is used to add the illusion of 3D details to a two-dimensional image. Parallax mapping simulates the change of perspective by calculating the texture offset, thereby enhancing the three-dimensional sense of the image. The principle of parallax mapping is to displace the two-dimensional texture coordinates along the perspective direction based on the height change data and the original texture map, and simulate the change of perspective by calculating the position of the offset texture coordinates corresponding to the current perspective, thereby increasing the three-dimensional sense and details of the image. The present disclosure can use the parallax mapping technology to offset the texture coordinates of the interactive part of the target terrain and the virtual object, and combine it with the offset of the terrain surface normal vector to simulate the "depression" feeling of the terrain surface. It should be noted that parallax mapping does not modify the terrain geometry. Figure 8 The diagram is a schematic diagram showing a method of offsetting texture coordinates according to parallax mapping according to an exemplary embodiment.
[0203] In another way, for a personal computer or a game console platform, the mesh accuracy of the deformation area can be refined in the pixel shader based on the tessellation technology of the graphics processing unit (GPU), that is, the mesh of the deformation position in the edited target terrain is refined, and the height of the edited target terrain is adjusted according to the height change data. The tessellation function of the GPU allows the number of mesh vertices and polygons to be dynamically increased. This function can be used to subdivide the terrain that interacts with the character and modify the height, so as to achieve the final interactive screen performance. Specifically, the tessellation technology mainly involves three parts: tessellation control shader: responsible for determining the tessellation level, setting the internal and external tessellation levels through internal variables, the higher the level, the finer the tessellation; tessellation engine: this is a fixed pipeline, responsible for converting complex surfaces into simple basic graphic elements such as points, lines, triangles, etc.; tessellation evaluation shader: runs on the vertices generated after the tessellation, and processes the vertex data generated by the tessellation engine. Fig. 9 The figure is a schematic diagram showing a method of refining the mesh accuracy of a deformation area according to a surface subdivision function according to an exemplary embodiment.
[0204] Therefore, for the terrain height change data, different algorithms can be selected according to the game running platform to be compatible with the interaction between the target terrain and the character of each platform. And because the parallax mapping technology can simulate the change of perspective by calculating the texture offset, thereby increasing the three-dimensional sense and details of the image, the GPU's surface subdivision function can subdivide the terrain with which the character interacts and modify the height, thereby achieving high-quality and efficient interactive screen performance, and then performing high-quality and efficient real-time rendering of the target terrain.
[0205] In summary, when the edited target terrain is deformed, rendering the edited target terrain by determining the terrain deformation and modifying the terrain geometry data can improve the rendering quality and rendering efficiency of the deformed target terrain.
[0206] The following describes the above-mentioned game terrain processing method by taking the target terrain as snow-covered terrain as an example:
[0207] 1) Snow-covered terrain production:
[0208] The production of the scene's basic terrain follows the built-in function of Unity. After turning on the snow editing mode, the following operations will occur: copy the height map and weight map of the current basic terrain and save them. The first account edits the snow texture weight and snow height. Save the scene terrain.
[0209] Optionally, the editing of the snow-covered terrain will not affect any data of the base terrain. Accordingly, the above method may include:
[0210] Receive a second edit request sent by the first account; the second edit request is used to request modification of the snow-covered terrain; in response to the second edit request, modify the initial height data and initial texture weight data of the snow-covered terrain to obtain third height data and third texture weight data corresponding to the snow-covered terrain; generate an edited target terrain based on the third height data and third texture weight data corresponding to the snow-covered terrain.
[0211] Optionally, if the base terrain needs to be modified again, the snow-covered terrain will be modified synchronously. On the one hand, for the height data, the initial height data of the snow-covered terrain can be modified synchronously corresponding to the modification method of the initial height data of the snow-covered terrain. On the other hand, for the texture weight data, the first texture weight data obtained by adjusting the base terrain and the initial texture weight data of the snow-covered terrain can be fused to obtain new texture weight data of the snow-covered terrain.
[0212] Optionally, the present disclosure also adds some procedural snow-covering functions: modifying the weight of the snow map layer according to the mask map, and supporting avoiding other obstacles in the scene (such as roads) when covering the snow; automatically modifying the height map of the snow-covered terrain according to the configured snow thickness parameters, etc.
[0213] 2) Snow-covered terrain rendering
[0214] Optionally, without virtual object interaction, the snow-covered terrain is rendered the same as the base terrain, by first converting the height map into mesh data in advance, and then blending the layers in the shader according to the weight map.
[0215] Optionally, the rendering of the interaction between the snow and the virtual object can be completed in two steps:
[0216] 2-1) Determine terrain deformation;
[0217] For the height change data, a map can be used to represent the height deformation degree of an area. For example, the position of the virtual object in the game, the motion deformation data corresponding to the virtual object and the preset brush map can be obtained. The motion deformation data may include but is not limited to: parameters such as the depth and width of the tread mark. Then, according to the preset brush map, the depth and width of the tread mark and other parameters are combined to form the height change data.
[0218] After determining the height change data, it is also necessary to calculate the change in normal. Specifically, after determining the height change data, the terrain vertex at the deformed position in the target terrain after the current deformation can be obtained. And the gradient of the vertex position corresponding to the terrain vertex at the deformed position is calculated by the Sobel operator. Then, the vertex normal vector is generated based on the gradient. Finally, the vertex normal vector is compared with the initial vertex normal vector of the terrain vertex at the deformed position before the deformation to generate the normal change data.
[0219] 2-2) Modify terrain geometry data
[0220] In the case where the device logged in by the second account is a mobile platform, the height change data is applied to the parallax mapping in the pixel shader to offset the texture coordinates of the edited target terrain.
[0221] When the device logged in by the second account is a personal computer or a game console platform, the mesh of the deformed position in the edited target terrain is refined based on the surface subdivision technology in the pixel shader, and the height of the edited target terrain is adjusted according to the height change data.
[0222] The embodiments of the present disclosure have the following beneficial effects:
[0223] 1) The present invention can use the target terrain as an increment of the base terrain to achieve synchronous modification of the height data of the target terrain and the base terrain, without having to modify the height data of the target terrain accordingly after each modification of the height data of the base terrain, thereby reducing the editing cost and maintenance cost of the height data of the terrain and improving the editing efficiency of the height data of the terrain. That is, only a small amount of work is required to complete the editing of the target terrain on the original base terrain. This makes up for the lack of support for the development and editing of target terrain in today's popular engines, and provides an easy-to-use, easy-to-maintain, and easy-to-develop target terrain production solution.
[0224] 2) The present disclosure can conveniently maintain two sets of terrain data and provide a dynamic switching function for the two sets of terrain. The dynamic switching function means that when editing the basic terrain, the target terrain will change along with it, and when editing the target terrain, the data of the basic terrain will not be affected.
[0225] 3) It provides a complete high-quality, high-efficiency target terrain and character interaction pipeline that is compatible with various platforms and can switch specific configurations based on the platform configuration.
[0226] 4) A complete solution from production and development to game runtime, suitable for the development of various electronic games with seasonal changes.
[0227] The disclosed embodiment also provides a game terrain processing device, Fig.10 FIG. 1 is a block diagram of a game terrain processing device according to an exemplary embodiment. Fig.10 As shown, the device comprises:
[0228] A first editing request sending module 41 is configured to execute and receive a first editing request sent by a first account; the first editing request is used to request synchronous modification of the target terrain and the basic terrain, and the target terrain is covered on the basic terrain;
[0229] The first height data generating module 43 is configured to execute, in response to the first editing request, adjusting the initial height data of the basic terrain to obtain first height data, and performing synchronous modification on the initial height data of the target terrain corresponding to the modification method of the initial height data of the basic terrain to obtain second height data corresponding to the target terrain; wherein the difference between the first height data and the initial height data of the basic terrain is equal to the difference between the second height data and the initial height data of the target terrain;
[0230] The texture weight data generating module 45 is configured to adjust the initial texture weight data of the base terrain to obtain first texture weight data, and fuse the first texture weight data with the initial texture weight data of the target terrain to obtain second texture weight data corresponding to the target terrain;
[0231] The terrain generating module 47 is configured to generate an edited target terrain according to the second height data corresponding to the target terrain and the second texture weight data corresponding to the target terrain.
[0232] In an optional embodiment, the first height data generating module includes:
[0233] A first edit request response unit is configured to increase or decrease the initial height data of the basic terrain by a preset height in response to the first edit request to obtain the first height data;
[0234] A synchronous modification unit is configured to perform synchronous modification on the initial height data of the target terrain corresponding to the modification method of the initial height data of the base terrain to obtain second height data corresponding to the target terrain, including:
[0235] a height increasing unit configured to increase the preset height to the initial height data of the target terrain by the preset height to obtain second height data;
[0236] The height reduction unit is configured to reduce the initial height data of the target terrain by the preset height when the initial height data of the base terrain is reduced by the preset height to obtain second height data.
[0237] In an optional embodiment, the texture weight data generating module includes:
[0238] A first texture adjustment unit is configured to adjust the initial texture weight data corresponding to each of the preset number of layers to obtain adjusted texture weight data corresponding to each of the preset number of layers;
[0239] A second texture adjustment unit is configured to generate the first texture weight data according to the adjusted texture weight data corresponding to each of the preset number of layers;
[0240] A weight adding unit is configured to add the adjusted texture weight data corresponding to each of the preset number of layers to obtain weight fusion data;
[0241] The weight fusion unit is configured to perform fusion processing on the initial texture weight data of the target terrain according to the weight fusion data to obtain second texture weight data corresponding to the target terrain; wherein the sum of the second texture weight data and the weight fusion data is 1.
[0242] In an optional embodiment, the device further comprises:
[0243] A second editing request receiving unit is configured to receive a second editing request sent by the first account; the second editing request is used to request modification of the target terrain;
[0244] a second edit request response unit, configured to modify the initial height data and the initial texture weight data of the target terrain in response to the second edit request, so as to obtain third height data and third texture weight data corresponding to the target terrain;
[0245] The edited target terrain determining unit is configured to generate the edited target terrain according to the third height data and the third texture weight data corresponding to the target terrain.
[0246] In an optional embodiment, the second edit request response unit includes:
[0247] A preset mask map acquisition subunit is configured to acquire a preset mask map; the preset mask map is used to control the display or hiding of the target terrain;
[0248] A covering subunit, configured to cover the preset mask map on the target terrain;
[0249] A third texture weight data generating subunit is configured to execute, in response to a parameter adjustment instruction for the preset mask map, to adjust the texture weight data of the target terrain to control display or hiding of the target terrain, and obtain third texture weight data corresponding to the target terrain;
[0250] The third height data generating subunit is configured to obtain a preset terrain thickness parameter, modify the initial height data of the target terrain based on the preset terrain thickness parameter, and obtain third height data corresponding to the target terrain.
[0251] In an optional embodiment, the device further comprises:
[0252] A first deformation determination module is configured to determine whether the edited target terrain has deformation during the process of the second account running the game application;
[0253] An information acquisition module is configured to acquire, when it is determined that the edited target terrain is deformed, a position of a virtual object in the game, motion deformation data corresponding to the virtual object, and a preset brush map;
[0254] A height change data generating module is configured to generate height change data according to the preset brush map, the position of the virtual object and the motion deformation data;
[0255] A normal change data generating module is configured to perform normal vector change analysis processing on the height change data to obtain normal change data;
[0256] The first rendering module is configured to modify the geometric data of the edited target terrain according to the height change data and the normal change data, so as to render the edited target terrain.
[0257] In an optional embodiment, the normal change data generating module includes:
[0258] A terrain vertex acquisition unit, configured to acquire terrain vertices at deformation positions in the edited target terrain according to the height change data;
[0259] A gradient determination unit, configured to determine the gradient of the vertex position corresponding to the terrain vertex at the deformation position;
[0260] A vertex normal vector generation unit, configured to generate a vertex normal vector based on a gradient of the vertex position;
[0261] The difference processing unit is configured to generate the normal change data according to the difference between the vertex normal vector and the initial vertex normal vector; the initial vertex normal vector is the vertex normal vector of the terrain vertex at the deformation position before the deformation.
[0262] In an optional embodiment, the rendering module includes:
[0263] A modified rendering unit is configured to execute, according to the game running platform, a parallax mapping technology or a surface subdivision technology to modify the height change data in a pixel shader, and in the pixel shader, according to the normal change map, modify the normal vector of the pixel in the edited target terrain to render the generated edited target terrain.
[0264] In an optional embodiment, the modifying rendering unit includes:
[0265] an offset subunit configured to apply the height change data to a parallax map in a pixel shader to offset the texture coordinates of the edited target terrain when the device logged in by the second account is a mobile platform;
[0266] The refinement subunit is configured to execute, when the device logged in by the second account is a personal computer or a game console platform, to refine the mesh of the deformed position in the edited target terrain based on the surface subdivision technology in the pixel shader, and adjust the height of the edited target terrain according to the height change data.
[0267] In an optional embodiment, the device further comprises:
[0268] A second deformation determination module is configured to determine whether the edited target terrain has deformation during the process of the second account running the game application;
[0269] The second rendering module is configured to convert the second height data corresponding to the edited target terrain into mesh data when it is determined that the edited target terrain does not have any deformation, and mix the various layers in the edited target terrain according to the second texture weight data and the mesh data to render the edited target terrain.
[0270] In an optional embodiment, the target terrain includes at least one of snow terrain, desert terrain, and wetland terrain.
[0271] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0272] In an exemplary embodiment, an electronic device for processing game terrain is also provided, including a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to implement the steps of any of the game terrain processing methods in the above embodiments when executing the instructions stored in the memory. The electronic device may be a terminal, a server or a similar computing device. For example, the electronic device is a server. Fig.11 It is a block diagram of an electronic device for game terrain processing according to an exemplary embodiment. The electronic device 50 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 51 (the central processing unit 51 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 53 for storing data, and one or more storage media 52 for storing application programs 523 or data 522 (for example, one or more mass storage devices). Among them, the memory 53 and the storage medium 52 can be short-term storage or permanent storage. The program stored in the storage medium 52 may include one or more modules, and each module may include a series of instruction operations in the electronic device. Furthermore, the central processing unit 51 can be configured to communicate with the storage medium 52 to execute a series of instruction operations in the storage medium 52 on the electronic device 50. The electronic device 50 may also include one or more power supplies 56, one or more wired or wireless network interfaces 55, one or more input and output interfaces 54, and / or one or more operating systems 521, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0273] The input / output interface 54 may be used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the electronic device 50. In one example, the input / output interface 54 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In an exemplary embodiment, the input / output interface 54 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0274] It can be understood by those skilled in the art that Fig.11 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig.11 More or fewer components as shown, or with Fig.11 Different configurations shown.
[0275] In an exemplary embodiment, a computer-readable storage medium is also provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the steps of any game terrain processing method in the above embodiments.
[0276] In an exemplary embodiment, a computer program product is also provided, including a computer program, which, when executed by a processor, implements the game terrain processing method provided in any of the above-mentioned embodiments.
[0277] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present disclosure can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0278] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0279] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for processing game terrain, characterized in that: The method comprises: receiving a first editing request sent by a first account; the first editing request is used to request synchronous modification of a target terrain and a basic terrain, wherein the target terrain is overlaid on the basic terrain; In response to the first editing request, the initial height data of the base terrain is adjusted to obtain first height data, and the initial height data of the target terrain is synchronously modified in a manner corresponding to the modification of the initial height data of the base terrain to obtain second height data corresponding to the target terrain; wherein the difference between the first height data and the initial height data of the base terrain is equal to the difference between the second height data and the initial height data of the target terrain; Adjusting the initial texture weight data of the base terrain to obtain first texture weight data, and fusing the first texture weight data with the initial texture weight data of the target terrain to obtain second texture weight data corresponding to the target terrain; The edited target terrain is generated according to the second height data corresponding to the target terrain and the second texture weight data corresponding to the target terrain.
2. The game terrain processing method according to claim 1, characterized in that: The step of adjusting the initial height data of the basic terrain in response to the first editing request to obtain first height data includes: In response to the first editing request, increasing or decreasing the initial height data of the basic terrain by a preset height to obtain the first height data; The performing synchronous modification on the initial height data of the target terrain in a manner corresponding to the modification of the initial height data of the base terrain to obtain second height data corresponding to the target terrain includes: In the case where a preset height is added to the initial height data of the base terrain, the preset height is added to the initial height data of the target terrain to obtain second height data; In the case where the initial height data of the basic terrain is reduced by the preset height, the initial height data of the target terrain is reduced by the preset height to obtain second height data.
3. The game terrain processing method according to claim 1, characterized in that: The basic terrain includes a preset number of layers, the initial texture weight data of the basic terrain is adjusted to obtain first texture weight data, and the initial height data of the target terrain is synchronously modified corresponding to the modification method of the initial height data of the basic terrain to obtain second height data corresponding to the target terrain, including: Adjusting the initial texture weight data corresponding to each of the preset number of layers to obtain adjusted texture weight data corresponding to each of the preset number of layers; Generate the first texture weight data according to the adjusted texture weight data corresponding to each of the preset number of layers; Adding the adjusted texture weight data corresponding to each of the preset number of layers to obtain weight fusion data; The initial texture weight data of the target terrain is fused according to the weight fusion data to obtain second texture weight data corresponding to the target terrain; wherein the sum of the second texture weight data and the weight fusion data is 1.
4. The method according to claim 1, characterized in that The method further comprises: receiving a second editing request sent by the first account, wherein the second editing request is used to request modification of the target terrain; In response to the second editing request, modify the initial height data and the initial texture weight data of the target terrain to obtain third height data and third texture weight data corresponding to the target terrain; The edited target terrain is generated according to the third height data and the third texture weight data corresponding to the target terrain.
5. The method according to claim 4, characterized in that The step of modifying the initial height data and the initial texture weight data of the target terrain to obtain third height data and third texture weight data corresponding to the target terrain includes: Obtaining a preset mask map; the preset mask map is used to control the display or hiding of the target terrain; Covering the preset mask map on the target terrain; In response to the parameter adjustment instruction for the preset mask map, the texture weight data of the target terrain is adjusted to control display or hiding of the target terrain, and third texture weight data corresponding to the target terrain is obtained; A preset terrain thickness parameter is obtained, and the initial height data of the target terrain is modified based on the preset terrain thickness parameter to obtain third height data corresponding to the target terrain.
6. The method according to any one of claims 1 to 5, characterized in that After generating the edited target terrain, the method further includes: During the process of running the game application by the second account, determining whether the edited target terrain has been deformed; When it is determined that the edited target terrain is deformed, obtaining a position of a virtual object in the game, motion deformation data corresponding to the virtual object, and a preset brush map; Generating height change data according to the preset brush map, the position of the virtual object and the motion deformation data; Performing normal vector change analysis on the height change data to obtain normal direction change data; The geometric data of the edited target terrain is modified according to the height change data and the normal change data to render the edited target terrain.
7. The method according to claim 6, characterized in that The performing normal vector change analysis processing on the height change data to obtain normal change data includes: According to the height change data, obtaining the terrain vertex at the deformation position in the edited target terrain; Determine the gradient of the vertex position corresponding to the terrain vertex at the deformation position; generating a vertex normal vector based on the gradient of the vertex position; The normal change data is generated according to the difference between the vertex normal vector and the initial vertex normal vector; the initial vertex normal vector is the vertex normal vector of the terrain vertex at the deformation position before the deformation.
8. The method according to claim 6, characterized in that The step of modifying the geometric data of the edited target terrain according to the height change data and the normal change data to render the edited target terrain comprises: According to the game running platform, the height change data is modified in the pixel shader using parallax mapping technology or surface subdivision technology, and in the pixel shader, the normal vector of the pixel in the edited target terrain is modified according to the normal change map to render the generated edited target terrain.
9. The method according to claim 8, characterized in that The modifying the height change data using a parallax mapping technique or a tessellation technique in a pixel shader comprises: In a case where the device logged in by the second account is a mobile platform, applying the height change data to parallax mapping in a pixel shader to offset texture coordinates of the edited target terrain; When the device logged in by the second account is a personal computer or a game console platform, the grid of the deformed position in the edited target terrain is refined based on the surface subdivision technology in the pixel shader, and the height of the edited target terrain is adjusted according to the height change data.
10. The method according to any one of claims 1 to 5, characterized in that After generating the edited target terrain, the method further includes: During the process of running the game application by the second account, determining whether the edited target terrain has been deformed; When it is determined that there is no deformation of the edited target terrain, the second height data corresponding to the edited target terrain is converted into mesh data, and each layer in the edited target terrain is mixed according to the second texture weight data and the mesh data to render the edited target terrain.
11. The method according to any one of claims 1 to 5, characterized in that The target terrain includes at least one of snow terrain, desert terrain, and wetland terrain.
12. A game terrain processing device, characterized in that: The device comprises: A first editing request sending module is configured to execute and receive a first editing request sent by a first account; the first editing request is used to request synchronous modification of the target terrain and the basic terrain, and the target terrain is covered on the basic terrain; A first height data generating module is configured to, in response to the first editing request, adjust the initial height data of the base terrain to obtain first height data, and perform synchronous modification on the initial height data of the target terrain corresponding to the modification method of the initial height data of the base terrain to obtain second height data corresponding to the target terrain; wherein the difference between the first height data and the initial height data of the base terrain is equal to the difference between the second height data and the initial height data of the target terrain; a texture weight data generating module, configured to adjust the initial texture weight data of the base terrain to obtain first texture weight data, and fuse the first texture weight data with the initial texture weight data of the target terrain to obtain second texture weight data corresponding to the target terrain; The terrain generation module is configured to generate an edited target terrain according to the second height data corresponding to the target terrain and the second texture weight data corresponding to the target terrain.
13. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the game terrain processing method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the game terrain processing method as claimed in any one of claims 1 to 11.