CN111508054A - Terrain construction method, device and equipment - Google Patents

Terrain construction method, device and equipment Download PDF

Info

Publication number
CN111508054A
CN111508054A CN202010288730.1A CN202010288730A CN111508054A CN 111508054 A CN111508054 A CN 111508054A CN 202010288730 A CN202010288730 A CN 202010288730A CN 111508054 A CN111508054 A CN 111508054A
Authority
CN
China
Prior art keywords
terrain
texture
target
block
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010288730.1A
Other languages
Chinese (zh)
Other versions
CN111508054B (en
Inventor
曹伟刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202010288730.1A priority Critical patent/CN111508054B/en
Publication of CN111508054A publication Critical patent/CN111508054A/en
Application granted granted Critical
Publication of CN111508054B publication Critical patent/CN111508054B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/04Texture mapping
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/55Radiosity
    • G06T5/70
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • G06T2207/10012Stereo images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20024Filtering details
    • G06T2207/20032Median filtering
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A90/00Technologies having an indirect contribution to adaptation to climate change
    • Y02A90/10Information and communication technologies [ICT] supporting adaptation to climate change, e.g. for weather forecasting or climate simulation

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Image Generation (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the invention provides a terrain construction method, a terrain construction device and terrain construction equipment, wherein the method comprises the following steps: the method comprises the steps of obtaining at least one drawing operation acting on any position, wherein the drawing operation carries height data of a terrain to be constructed, determining a texture area involved by each drawing operation, determining at least one target ground block according to the involved texture area, and constructing the terrain of the target ground block according to the height data. According to the embodiment of the invention, the construction efficiency and effect of the terrain are improved, and the game experience of a user is further improved.

Description

Terrain construction method, device and equipment
Technical Field
The embodiment of the invention relates to the technical field of image processing, in particular to a terrain construction method, a terrain construction device and terrain construction equipment.
Background
With the increasing diversification of game functions and the increasing scale of 3D mobile game scenes, the terrain construction in the game scenes becomes an important step in the scene construction process. At present, a map editor is embedded in a 3D mobile game and has been involved in some games, and terrain editing in a map is an important aspect for scene construction. Currently, due to the consideration of performance and implementation complexity, it is a conventional practice to construct a terrain by using a model splicing scheme. In the process of terrain construction, a plurality of different terrains can be involved, and the different terrains are spliced to obtain a terrain map in the game. Because the landforms related to different terrains are different, when the terrains are constructed, a terrain model is generally determined for each terrain, and then the different terrain models are spliced to obtain a terrain map.
However, the map editor embedded in the existing game has limited expression capacity, the terrain is formed by splicing, the appearance of the terrain is determined by a preset terrain model block, the complexity is low, the fine terrain cannot be described, and the controllability of a player is poor; the method is difficult to mix with the texture of the earth surface, and the drawing of the texture of the earth surface is generally limited around the terrain because the preset terrain is inconvenient to process the junction of the earth surface and the terrain; lack elasticity, can't adjust in real time according to equipment performance, because every topography type all needs the designer to export the topography model that corresponds according to the concatenation scheme, then manual concatenation again, waste time and energy, and the model piece appears to the condition uneven, that has the crack easily, and the effect that leads to after the concatenation is poor, influences user's gaming experience.
Disclosure of Invention
The embodiment of the invention provides a terrain construction method, a terrain construction device and terrain construction equipment, which are used for improving a terrain generation effect and further improving game experience of a user.
In a first aspect, an embodiment of the present invention provides a terrain construction method, including: obtaining at least one drawing operation acting on any position, wherein the drawing operation carries height data of a terrain to be constructed; determining a texture region involved in each of the rendering operations, and determining at least one target map block based on the involved texture region; and constructing the terrain of the target ground block according to the height data.
Optionally, the determining a texture region involved in each of the rendering operations includes: acquiring a parameter configuration value of the brush; determining texture lattices involved in each drawing operation of the brush according to the parameter configuration values, wherein each surface block comprises a plurality of texture lattices with equal areas; and determining a texture region according to the texture grid.
Optionally, the determining at least one target map block according to the texture region involved includes: determining a target surface block to which the texture grid related to the drawing operation belongs; if the texture lattices involved in the drawing operation belong to the same map block, only one target map block is determined; and if the texture lattices involved in the drawing operation do not belong to the same map block, correspondingly determining a plurality of target map blocks.
Optionally, the constructing the terrain of the target terrain block according to the height data includes: dividing the target surface block into a preset number of terrain grids, and determining a height value of each vertex in each terrain grid according to the height data, wherein the preset number is 16 × 16, 32 × 32, 64 × 64 or 128 × 128; and constructing triangular surface patches according to the terrain lattices, and calculating uv values, mixing coefficients and vertex normals of each triangular surface patch so as to finish the construction of the target terrain surface block terrain.
Optionally, after constructing the triangular patch according to the terrain lattice, the method further includes: in the target surface block, traversing each triangular surface patch one by one according to a preset sequence, wherein the height value data of each triangular surface patch is equal; when the traversed target triangular patch does not meet the merging condition, adding the target triangular patch into a merged list; when the traversed target triangular patch meets the merging condition, merging the target triangular patch, and adding the merged patch into a list to be merged; merging the patches in the list to be merged according to a preset recursion number, and adding the merged patches into the merged list to form a new merged list; and calculating uv values, mixing coefficients and vertex normals of the patches in the new merged list to complete the construction of the target surface block terrain.
Optionally, the brush used in the drawing operation is implemented by using a noise map generated by Berlin noise perlin-noise; after the updating the terrain of the target terrain block according to the height data, further comprising: and carrying out filtering processing on the updated target earth surface block.
Optionally, before the obtaining at least one drawing operation acting on any position, the method further includes: acquiring a surface area of a terrain to be updated; dividing the surface area into surface blocks with equal areas, wherein the size of each surface block is 200 x 200.
Optionally, before the obtaining of the parameter configuration value of the brush, the method further includes: dividing each surface block into a plurality of texture grids with equal areas, wherein the number of the texture grids contained in each surface block is 128.
Optionally, the method further includes: and for each surface block which is not involved in the drawing operation, setting the terrain of the surface block to be a rectangular patch model, wherein the height value of the rectangular patch model is zero.
In a second aspect, an embodiment of the present invention provides a terrain building apparatus, including:
the device comprises a touch module, a display module and a control module, wherein the touch module is used for acquiring at least one drawing operation acting on any position, and the drawing operation carries height data of a terrain to be constructed;
a processing module for determining a texture region involved in each of said rendering operations and determining at least one target map block based on said involved texture region;
the processing module is further configured to construct a terrain of the target surface block according to the height data.
Optionally, the processing module is further configured to: acquiring a parameter configuration value of the brush; determining texture lattices involved in each drawing operation of the brush according to the parameter configuration values, wherein each surface block comprises a plurality of texture lattices with equal areas; and determining a texture region according to the texture grid.
Optionally, the processing module is further configured to: determining a target surface block to which the texture grid related to the drawing operation belongs; if the texture lattices involved in the drawing operation belong to the same map block, only one target map block is determined; and if the texture lattices involved in the drawing operation do not belong to the same map block, correspondingly determining a plurality of target map blocks.
In a third aspect, an embodiment of the present invention provides terrain building equipment, including: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing the computer-executable instructions stored by the memory causes the at least one processor to perform the terrain construction method of any of the first aspects.
In a fourth aspect, the present invention provides a computer-readable storage medium, in which computer-executable instructions are stored, and when a processor executes the computer-executable instructions, the terrain building method according to any one of the first aspect is implemented.
After the scheme is adopted, the texture area involved in the drawing operation can be determined according to the obtained at least one drawing operation acting on any position, then the target surface block where the texture area is located is determined, the terrain of the target surface block is updated according to the height data carried in the drawing operation, and then the construction of the terrain of the target surface block is completed.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic application diagram of a terrain construction method according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a terrain construction method according to an embodiment of the present invention;
FIG. 3 is a schematic view of an arc provided by an embodiment of the present invention;
FIG. 4 is a diagram illustrating an application of a target-specific map block according to an embodiment of the present invention;
fig. 5a is a schematic diagram of an application of a patch provided in an embodiment of the present invention before merging;
fig. 5b is a schematic diagram of an application of the merged patch according to the embodiment of the present invention;
FIG. 6 is a schematic diagram illustrating an application of Gaussian filtering according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a terrain building apparatus according to an embodiment of the present invention;
fig. 8 is a schematic diagram of a hardware structure of a surface construction apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In the construction of the game scene, the earth surface can be constructed firstly, and then the terrain can be constructed on the earth surface after the earth surface is constructed.
When the ground surface is constructed, the mixed texture can be adopted for construction, wherein the rgb channel of the mixed texture records the mixed coefficients of four ground surface textures, because the sum of the four mixed coefficients is 1, and the a channel is used for storing the height of the ground surface.
Furthermore, in implementations of the landscape, the landscape is partitioned, each tile may be 200 × 200 in size, and the height of the character may be 5. The unit of the earth surface size and the character height can be set according to actual conditions, and can be rice or decimeter, and is not limited specifically here. A surface or terrain is generally referred to as a surface patch chunk. In each original terrain, four 512-by-512 square continuous textures can be used as the basic textures of the ground surface, and each ground surface is formed by mixing the four textures according to a mixing coefficient.
In the prior art, when a terrain is constructed on the ground surface, the terrain is generally formed by splicing terrain models. Because the appearance of topography is decided by predetermineeing topography model piece, the complexity is low, can't describe meticulous topography, the player controllability is poor, and the topography model of artifical output is difficult to mix with the texture of earth's surface, inconvenient processing earth's surface and topography juncture, the drawing of the peripheral earth's surface texture of topography has been restricted, and every topography type all needs fine arts to export the topography model according to the concatenation scheme, cover all topography types, the model that needs to be handled is more, art designer's work load has been increased, it is hard to waste time, and at the in-process of concatenation, excessively rely on art designer's subjectivity, the model piece appears easily to the inequality, the condition that has the crack, the effect after leading to the concatenation is poor, influence user's gaming experience.
Based on the problems, the method and the device for constructing the terrain comprise the steps that firstly, the height data of the terrain to be constructed are obtained through drawing operation, then the corresponding terrain surface block is determined according to the texture area related to the obtained height data of the terrain to be constructed, then the terrain of the determined terrain surface block is constructed, and further the construction of the terrain of the whole terrain surface area is achieved, so that the construction efficiency and the construction effect of the terrain in the terrain surface are improved, and further the game experience of a user is improved.
Fig. 1 is a schematic application diagram of a terrain construction method according to an embodiment of the present invention, and as shown in fig. 1, the application scenario is an application scenario in a game, where the application scenario includes a ground surface, a terrain constructed on the ground surface, and a virtual character object. Different terrains are represented by different gray levels, splicing among the terrains is natural, no crack exists, the boundary is not obvious, and the game experience of a user is improved.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 2 is a schematic flowchart of a terrain construction method according to an embodiment of the present invention, where an execution main body of the terrain construction method according to the embodiment may be a device for executing a rendering method of a ground surface in a game, where the rendering device of the ground surface in the game may be implemented by software and/or hardware, and in the embodiment, the device may be integrated on an electronic device, for example: as shown in fig. 2, the method specifically includes the following steps:
s201: at least one drawing operation acting on any position is obtained, wherein the drawing operation carries height data of the terrain to be constructed.
Specifically, in the ground surface of the game scene, the drawing operation may be performed at any position of the ground surface by the brush. Before the drawing operation is executed, the parameter value of the brush can be set according to the actual requirement in the game scene implementation process. For example, a height value drawn by the brush may be set, and a width, transparency, hardness, and the like of the brush may also be set. The hardness of the brush is used for representing the strength of the edge and the middle of the graph for drawing operation, the strength of the edge is usually small, the strength of the middle is usually large, and the value is between 0.0 and 1.0.
Further, argb is a color pattern having four channels, transparency (Alpha), Red (Red), Green (Green), and Blue (Blue), respectively, through which the texture and terrain height of the ground surface in the scene can be recorded. For example, the mixing coefficients may be recorded using the rgb channels in a 128 x 128 argb texture, and the a channels the height data of the terrain. When the 128 × 128 mixed texture is spread on the chunk, the chunk is divided into 128 × 128 small grids, which may be called texture grids, that is, corresponding to the pixels in the texture.
S202: determining a texture region involved in each of said rendering operations and determining at least one target map block based on said involved texture region.
Specifically, during the drawing process of the brush, it is first required to determine the area covered by the brush at the current position, and this area may be referred to as a texture area. The shape of the texture region may be set according to actual requirements, and for example, the shape may be a circle, a square, an ellipse, an irregular shape, or the like.
Furthermore, as can be seen from the foregoing description, the terrain is partitioned, i.e., the entire terrain area is partitioned into a plurality of terrain blocks. The boundary position of each map block is determined, and the related target map block can be determined according to the boundary position of the texture region related to the drawing operation. Namely, the target ground table block is a ground table block in which the height data involved in the drawing operation is not zero.
If the texture region involved in the rendering operation is in a target map block, a target map block is determined. And if the texture region involved in the drawing operation is in the plurality of target map blocks, determining the plurality of target map blocks.
S203: and constructing the terrain of the target ground block according to the height data.
Specifically, the height data is a height value corresponding to each area of the terrain to be constructed, and is a set of a plurality of height values. And automatically constructing the ground rows of the involved target ground surface blocks according to the height data, and finally completing the construction of the terrain in the whole ground surface area.
In addition, the terrain may be divided into raised terrain and lowered terrain, and in a channel, low-to-high values may need to be recorded, and in order to accurately represent the terrain, the elevation data may need to include an indication of the elevation or lowering of the terrain in addition to the elevation value of the terrain. In one embodiment, this can be expressed as follows:
texture value [0,0.5] - > height value [ -1.0,0 ].
Texture value [0.5,1.0] - > height value [0,1.0 ].
The mapping relation from the texture value to the height map is as follows:
(a) -2 a-1.0, where the texture value 0.5 represents flat, below 0.5 represents decreasing and above 0.5 represents increasing. That is, a texture value of [0,0.5] represents the terrain as a lowered terrain, and a texture value of [0.5,1.0] represents the terrain as a raised terrain.
After the scheme is adopted, the texture area involved in the drawing operation can be determined according to the obtained at least one drawing operation acting on any position, then the target surface block where the texture area is located is determined, the terrain of the target surface block is updated according to the height data carried in the drawing operation, and then the construction of the terrain of the target surface block is completed, and each terrain type does not need to be output by an art designer according to a splicing scheme, so that the construction efficiency and effect of the terrain in the surface are improved, and the game experience of a user is also improved.
Based on the method of fig. 2, the present specification also provides some specific embodiments of the method, which are described below.
In a specific embodiment, the determining the texture region involved in each of the rendering operations includes:
and acquiring the parameter configuration value of the brush. And determining the texture lattices involved in each drawing operation of the brush according to the parameter configuration values, wherein each ground table block comprises a plurality of texture lattices with equal areas. And determining a texture region according to the texture grid.
Specifically, when a terrain is constructed in the ground surface, the terrain can be constructed by taking ground surface blocks as units, each ground surface block can be divided into a plurality of small lattices with equal areas, and the small lattices can be called as texture lattices in a process of drawing heights by a brush, namely, a process of coloring the small lattices. Illustratively, the size of the surface block is 200 × 200, the surface block is divided into 128 × 128 texture grids, each texture grid represents one pixel, and the graph drawn by the brush is a circle. When the brush draws a circle, we need to determine which texture grids belong to the circle, i.e. the texture area involved by the brush can be determined. Wherein, height _ accuracy can be used to represent height precision value 128/200, and the larger this value, the denser the grid.
It should be noted that when the brush is used to draw on the surface block, a circle is generally generated around the brush, and a continuous area is generated along with the dragging of the brush. In this embodiment, the lattice occupied by the circle is graphically a deformation of the circle drawing algorithm, the brush algorithm may be Bresenham circle drawing algorithm, and how to obtain the texture lattice is described in detail as follows:
first, one-eighth of a circular arc is calculated. X for a circle F (x, y)2+y2-R2For points on the circle, F (x, y) ═ 0, for points outside the circle, F (x, y) > 0, and for points inside the circle, F (x, y)<0。
Fig. 3 is a schematic diagram of an arc according to an embodiment of the present invention, and as shown in fig. 3, P, P1 and P2 respectively represent a lattice, and if it is known that a point P is on a circle, the following method is combined with a midpoint determination method to determine whether the next point of the arc is P1 or P2, i.e., which texture lattice belongs to a texture region. Wherein, the midpoint M is P2 outside the circular arc, and P1 inside the circular arc. P point coordinate is (χ)p,yp) The M point coordinate is (χ)p+1,yp-0.5), P1 point coordinate is (χ)p+1,yp) The P2 point coordinate is (χ)p+1,yp-1)。
Structural discriminant:
d0=F(M)=F(χp+1,yp-0.5)=(χp+1)2+(yp-0.5)2-R2
if d is less than 0, P1 is taken, and the decision derivation for the next hybrid trellis is:
d1=F(M)=F(χp+2,yp-0.5)=(χp+2)2+(yp-0.5)2-R2=d0+2χp+3;
increment of dΔ1=2χp+3。
If d > is 0, then P2 is taken, and the decision derivation formula of the next texture grid is:
d2=F(M)=F(χp+2,yp-1.5)=(χp+2)2+(yp-1.5)2-R2=d0+2(χp-yp)+5;
increment of dΔ2=2(χp-yp)+5;
If P is (0, R), then d0=1.25-R。
It should be noted that, converting the above discriminant into an integer calculation, both sides of the equation are multiplied by 2, and the following changes are made:
2d1=2d0+4χp+6;
2d2=2d0+4(χp-yp)+10;
2d0=2*(1.25-R)=2.5-2R=3-2R。
since the radius R of the circle is an integer and greater than 2, the following is continuously rewritten without changing the positive or negative of the right side of the equation:
d0=3-2R;
d1=d0+4χp+6;
d2=d0+4(χp-yp)+10。
the incremental formula is:
dΔ1=4χp+6;
dΔ2=4(χp-yp)+10。
in conclusion, only according to the increment dΔ1、dΔ2That is, a discrimination derivation formula is obtained for each next texture grid, and points on the circular arc are determined based on the positive and negative of the discrimination derivation formula.
Then, according to the eight symmetry of the circle, other 7 points are obtained, and a circular ring is obtained.
Finally, the resulting circles, i.e., the texture lattices within the circles, are filled to form texture regions.
In one embodiment, the fill circle may be drawn in the following manner:
Figure BDA0002449584170000091
Figure BDA0002449584170000101
in a specific embodiment, the determining at least one target map block according to the texture region involved may include:
and determining a target map block to which the texture grid involved in the drawing operation belongs.
And if the texture grids involved in the drawing operation belong to the same map block, only one target map block is determined.
And if the texture lattices involved in the drawing operation do not belong to the same map block, correspondingly determining a plurality of target map blocks.
Specifically, the surface block involved in the rendering operation is referred to as a target surface block. In the brush drawing process, the height filling can be performed with the texture grid as the minimum unit. And then determining the surface block where the texture grid is located, namely determining the target surface block related to the drawing operation.
In determining the surface block where the texture grid is located, the texture grid that is highly filled may be in one surface block or in multiple surface blocks. If the highly filled texture grid is in a map block, a target map block is correspondingly determined. And if the highly filled texture grids are in a plurality of map blocks, correspondingly determining a plurality of target map blocks.
Fig. 4 is a schematic diagram illustrating an application of a target-specific surface block according to an embodiment of the present invention, in this embodiment, a circular region is a texture region, and a texture grid forming the texture region is distributed in the surface block a and the surface block B, so that two target surface blocks are involved in a drawing operation, namely, the surface block a and the surface block B.
In a specific embodiment, the constructing the terrain of the target block according to the height data may include:
and dividing the target surface block into a preset number of terrain grids, and determining a height value of each vertex in each terrain grid according to the height data, wherein the preset number is 16 × 16, 32 × 32, 64 × 64 or 128 × 128.
And constructing triangular surface patches according to the terrain lattices, and calculating uv values, mixing coefficients and vertex normals of each triangular surface patch so as to finish the construction of the target terrain surface block terrain.
Specifically, after the target surface block is determined, the target surface block may be divided into a plurality of terrain grids in order to improve the authenticity of the terrain construction. The height values of the vertices of each terrain lattice are associated with height data of the texture lattice in which the vertices reside. For example, if four vertices of a terrain lattice are all in a texture lattice with a height data value of 1, the height value of each vertex of the terrain lattice is 1. And then forming triangular surface patches according to the terrain lattices, and calculating uv values, mixing coefficients and vertex normals of the triangular surface patches so as to complete the construction of the target terrain surface block terrain. The uv value, the blending coefficient and the vertex normal of each triangular patch can be calculated by using the implementation manner in the prior art, and the calculation is not limited in detail here.
In addition, when the target surface block is divided into a plurality of terrain grids, the number of the divided terrain grids can be selected according to actual requirements. For example, the number of divisions may be 16 × 16, 32 × 32, 64 × 64, or 128 × 128. If the requirement for the terrain pixels is high, the number of the divisions may be set to be larger, for example, 128 × 128 divisions may be performed. If the requirement on the terrain pixels is not high, the number of the divisions can be set to be smaller, for example, the divisions can be divided into 16 × 16 or 32 × 32.
In a specific embodiment, after constructing the triangular patch according to the terrain lattice, the method further includes:
and in the target table block, traversing each triangular patch one by one according to a preset sequence, wherein the height value data of each triangular patch is equal.
And when the traversed target triangular patch does not meet the merging condition, adding the target triangular patch into the merged list.
And when the traversed target triangular patch meets the merging condition, merging the target triangular patch, and adding the merged patch into a list to be merged.
And merging the patches in the list to be merged according to the preset recursion times, and adding the merged patches into the merged list to form a new merged list.
And calculating uv values, mixing coefficients and vertex normals of the patches in the new merged list to complete the construction of the target surface block terrain.
Specifically, if a 16 × 16 target surface block is divided into 256 terrain grids, 512 triangular patches are generated, and a map with 10 × 10 target surface blocks has 512 × 100 triangular patches. The number of the triangular patches is huge, and the processing workload is large when the triangular patches are processed. Then, in one surface area, the terrain is mostly flat, and therefore, in order to improve the processing efficiency, the patches may be merged according to the target surface block.
In a target table block, each triangular patch can be traversed one by one according to a preset sequence, wherein the preset sequence can be from left to right and from bottom to top, each triangular patch is traversed one by one, the triangular patch G is merged with the immediately adjacent left G _ left and lower G _ down merged patches, if merging is possible, the merged patch is added into a list to be merged, and merging processing operation is waited for next time. And if the triangle patch G cannot be merged, directly adding the triangle patch G into the merged list, and constructing the terrain after all the patches are merged.
In this embodiment, the preset recursion number is set to 2 times.
In addition, in order to simplify the calculation, only patches having the same height value may be merged without merging the diagonal planes. And the height value of the patch is height data corresponding to the texture grid where the vertex of the patch is located. The basis of merging is that the topographic lattices where the two surface patches are located are the same height, and the vertexes are connected. After the dough sheets are combined, the number of the dough sheets can be greatly reduced, and the efficiency of subsequent terrain construction is improved.
Fig. 5a is a schematic diagram of an application of the embodiment of the present invention before merging the patches, where in this embodiment, the number of the patches is 512.
Fig. 5b is a schematic diagram of an application after merging of patches according to an embodiment of the present invention, in which the number of merged patches is 34, and no merging operation is performed on patches with height values different from zero.
In one embodiment, the brush used in the drawing operation is implemented by applying a noise map generated by Berlin noise perlin-noise.
After the updating the terrain of the target terrain block according to the height data, further comprising:
and carrying out filtering processing on the updated target earth surface block.
Specifically, the random topography can be drawn by a brush. For example, the parameters of perlin-noise can be adjusted: and the persistence is 0.25, the frequency multiplication is 4 to generate a noise map, and then the terrain brush with randomness is generated through the noise map.
However, when a random brush is applied using a noise map generated by perlin-noise, the resulting terrain is somewhat sharp and a standard noise smoothing process, i.e. filtering, can be used to make the terrain smoother.
The common filtering means includes mean filtering, median filtering, and gaussian filtering, and the general idea is to perform weighted calculation on the final value of a certain pixel by using the pixel and several peripheral pixel values according to weight. In the embodiment, gaussian filtering, namely gaussian blurring, can be adopted, and a good smoothing effect can be achieved under the condition that the terrain trend is not changed. The weight of the gaussian filter is normally distributed, and the weight is the distribution probability, and can be determined according to the following expression:
Figure BDA0002449584170000131
wherein, x and y represent the row-column coordinate of pixel respectively, and sigma represents the distribution concentration, and the smaller sigma, the thinner the probability distribution curve is, the more concentrated sigma is, and the fatter the curve is, the more dispersed the curve is.
The core of gaussian filtering is to calculate a gaussian kernel, which is used to filter each pixel of an image, and the parameters affecting the gaussian kernel mainly include σ and blur radius.
As shown in fig. 6, a schematic diagram of application of gaussian filtering provided by an embodiment of the present invention, in this embodiment, when a blur radius is 1 and filtering calculation is performed on a certain pixel, it is necessary to participate in weight calculation together with another 8 points in the direction of a peripheral radius of 1. The point for each direction can be calculated by the following formula:
Figure BDA0002449584170000132
then, the value determined by calculation is normalized, and the Gaussian kernel can be calculated.
For example, when σ is 3 and the blur radius is 2, the following gaussian kernel can be generated:
[0.03175640478730202,0.037515755742788315,0.03965894505381584,0.037515755742788315,0.03175640478730202,0.037515755742788315,0.04431962966918945,0.0468515083193779,0.04431962966918945,0.037515755742788315,0.03965894505381584,0.0468515083193779,0.049528032541275024,0.0468515083193779,0.03965894505381584,0.037515755742788315,0.04431962966918945,0.0468515083193779,0.04431962966918945,0.037515755742788315,0.03175640478730202,0.037515755742788315,0.03965894505381584,0.037515755742788315,0.03175640478730202]
then, the region where the brush passes through is subjected to the filtering removal operation through the Gaussian kernel, and the height can be smoothed.
In a specific embodiment, before the obtaining at least one drawing operation acting on any position, the method may further include:
and acquiring the surface area of the terrain to be updated.
Dividing the surface area into surface blocks with equal areas, wherein the size of each surface block is 200 x 200.
In a specific embodiment, before the obtaining the parameter configuration value of the brush, the method may further include: dividing each surface block into a plurality of texture grids with equal areas, wherein the number of the texture grids contained in each surface block is 128.
In a specific embodiment, the method may further include:
and for each surface block which is not involved in the drawing operation, setting the terrain of the surface block to be a rectangular patch model, wherein the height value of the rectangular patch model is zero.
Specifically, when the brush draws the terrain, the terrain may be updated locally according to the surface blocks. If the surface block is flat, namely the height value is zero, the terrain construction is not carried out, the surface block defaults to be a rectangular patch model, additional processing is not needed, and the terrain construction efficiency is improved.
Based on the same idea, an embodiment of the present specification further provides a device corresponding to the foregoing method, and as shown in fig. 7, a schematic structural diagram of a terrain building device provided in an embodiment of the present invention may include:
the touch module 701 is configured to acquire at least one drawing operation that acts on any position, where the drawing operation carries height data of a terrain to be constructed.
A processing module 702, configured to determine a texture region involved in each of the rendering operations, and determine at least one target map block according to the involved texture region.
The processing module 702 is further configured to construct a terrain of the target surface block according to the height data.
In a specific embodiment, the processing module may be further configured to:
and acquiring the parameter configuration value of the brush.
And determining the texture lattices involved in each drawing operation of the brush according to the parameter configuration values, wherein each ground table block comprises a plurality of texture lattices with equal areas.
And determining a texture region according to the texture grid.
In a specific embodiment, the processing module may be further configured to:
and determining a target map block to which the texture grid involved in the drawing operation belongs.
And if the texture grids involved in the drawing operation belong to the same map block, only one target map block is determined.
And if the texture lattices involved in the drawing operation do not belong to the same map block, correspondingly determining a plurality of target map blocks.
In a specific embodiment, the processing module may be further configured to:
and dividing the target surface block into a preset number of terrain grids, and determining a height value of each vertex in each terrain grid according to the height data, wherein the preset number is 16 × 16, 32 × 32, 64 × 64 or 128 × 128.
And constructing triangular surface patches according to the terrain lattices, and calculating uv values, mixing coefficients and vertex normals of each triangular surface patch so as to finish the construction of the target terrain surface block terrain.
In a specific embodiment, the processing module may be further configured to:
and in the target table block, traversing each triangular patch one by one according to a preset sequence, wherein the height value data of each triangular patch is equal.
And when the traversed target triangular patch does not meet the merging condition, adding the target triangular patch into the merged list.
And when the traversed target triangular patch meets the merging condition, merging the target triangular patch, and adding the merged patch into a list to be merged.
And merging the patches in the list to be merged according to the preset recursion times, and adding the merged patches into the merged list to form a new merged list.
And calculating uv values, mixing coefficients and vertex normals of the patches in the new merged list to complete the construction of the target surface block terrain.
In a specific embodiment, the processing module may be further configured to:
the brush used for the drawing operation is implemented by applying a noise map generated by Berlin noise perlin-noise.
And carrying out filtering processing on the updated target earth surface block.
In a specific embodiment, the touch module may further be configured to:
and acquiring the surface area of the terrain to be updated.
Dividing the surface area into surface blocks with equal areas, wherein the size of each surface block is 200 x 200.
In a specific embodiment, the touch module may further be configured to:
dividing each surface block into a plurality of texture grids with equal areas, wherein the number of the texture grids contained in each surface block is 128.
In a specific embodiment, the processing module may be further configured to:
and for each surface block which is not involved in the drawing operation, setting the terrain of the surface block to be a rectangular patch model, wherein the height value of the rectangular patch model is zero.
The apparatus provided in the embodiment of the present invention may implement the method in the embodiment shown in fig. 2, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 8 is a schematic diagram of a hardware structure of a surface construction apparatus according to an embodiment of the present invention. As shown in fig. 8, the apparatus 800 provided in this embodiment includes: at least one processor 801 and a memory 802. The processor 801 and the memory 802 are connected by a bus 803.
In a specific implementation, at least one processor 801 executes computer-executable instructions stored by the memory 802, so that at least one processor 801 executes the method in the above-described method embodiments.
For a specific implementation process of the processor 801, reference may be made to the above method embodiments, which have similar implementation principles and technical effects, and details of this embodiment are not described herein again.
In the embodiment shown in fig. 8, it should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
The memory may comprise high speed RAM memory and may also include non-volatile storage NVM, such as at least one disk memory.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
The embodiment of the invention also provides a computer-readable storage medium, wherein a computer execution instruction is stored in the computer-readable storage medium, and when a processor executes the computer execution instruction, the earth surface construction method of the embodiment of the method is realized.
The computer-readable storage medium may be implemented by any type of volatile or non-volatile memory device or combination thereof, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk. Readable storage media can be any available media that can be accessed by a general purpose or special purpose computer.
An exemplary readable storage medium is coupled to the processor such the processor can read information from, and write information to, the readable storage medium. Of course, the readable storage medium may also be an integral part of the processor. The processor and the readable storage medium may reside in an Application Specific Integrated Circuits (ASIC). Of course, the processor and the readable storage medium may also reside as discrete components in the apparatus.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (14)

1. A terrain building method, comprising:
obtaining at least one drawing operation acting on any position, wherein the drawing operation carries height data of a terrain to be constructed;
determining a texture region involved in each of the rendering operations, and determining at least one target map block based on the involved texture region;
and constructing the terrain of the target ground block according to the height data.
2. The method according to claim 1, wherein the determining the texture region involved in each of the rendering operations comprises:
acquiring a parameter configuration value of the brush;
determining texture lattices involved in each drawing operation of the brush according to the parameter configuration values, wherein each surface block comprises a plurality of texture lattices with equal areas;
and determining a texture region according to the texture grid.
3. The method according to claim 2, wherein said determining at least one target map block based on said texture region involved comprises:
determining a target surface block to which the texture grid related to the drawing operation belongs;
if the texture lattices involved in the drawing operation belong to the same map block, only one target map block is determined;
and if the texture lattices involved in the drawing operation do not belong to the same map block, correspondingly determining a plurality of target map blocks.
4. The method of claim 1, wherein said constructing the terrain of the target surface block from the elevation data comprises:
dividing the target surface block into a preset number of terrain grids, and determining a height value of each vertex in each terrain grid according to the height data, wherein the preset number is 16 × 16, 32 × 32, 64 × 64 or 128 × 128;
and constructing triangular surface patches according to the terrain lattices, and calculating uv values, mixing coefficients and vertex normals of each triangular surface patch so as to finish the construction of the target terrain surface block terrain.
5. The method of claim 4, further comprising, after the constructing triangular patches from the terrain lattice:
in the target surface block, traversing each triangular surface patch one by one according to a preset sequence, wherein the height value data of each triangular surface patch is equal;
when the traversed target triangular patch does not meet the merging condition, adding the target triangular patch into a merged list;
when the traversed target triangular patch meets the merging condition, merging the target triangular patch, and adding the merged patch into a list to be merged;
merging the patches in the list to be merged according to a preset recursion number, and adding the merged patches into the merged list to form a new merged list;
and calculating uv values, mixing coefficients and vertex normals of the patches in the new merged list to complete the construction of the target surface block terrain.
6. The method according to any one of claims 1 to 5, wherein the drawing operation is performed using a brush generated by using Berlin noise perlin-noise;
after the updating the terrain of the target terrain block according to the height data, further comprising:
and carrying out filtering processing on the updated target earth surface block.
7. The method according to any one of claims 1-5, wherein prior to said obtaining at least one rendering operation acting on any one location, further comprising:
acquiring a surface area of a terrain to be updated;
dividing the surface area into surface blocks with equal areas, wherein the size of each surface block is 200 x 200.
8. The method of claim 2, further comprising, prior to the obtaining the parameter configuration values for the brush:
dividing each surface block into a plurality of texture grids with equal areas, wherein the number of the texture grids contained in each surface block is 128.
9. The method of any one of claims 1-5, further comprising:
and for each surface block which is not involved in the drawing operation, setting the terrain of the surface block to be a rectangular patch model, wherein the height value of the rectangular patch model is zero.
10. A terrain building apparatus, comprising:
the device comprises a touch module, a display module and a control module, wherein the touch module is used for acquiring at least one drawing operation acting on any position, and the drawing operation carries height data of a terrain to be constructed;
a processing module for determining a texture region involved in each of said rendering operations and determining at least one target map block based on said involved texture region;
the processing module is further configured to construct a terrain of the target surface block according to the height data.
11. The apparatus of claim 10, wherein the processing module is further configured to:
acquiring a parameter configuration value of the brush;
determining texture lattices involved in each drawing operation of the brush according to the parameter configuration values, wherein each surface block comprises a plurality of texture lattices with equal areas;
and determining a texture region according to the texture grid.
12. The apparatus of claim 11, wherein the processing module is further configured to:
determining a target surface block to which the texture grid related to the drawing operation belongs;
if the texture lattices involved in the drawing operation belong to the same map block, only one target map block is determined;
and if the texture lattices involved in the drawing operation do not belong to the same map block, correspondingly determining a plurality of target map blocks.
13. A terrain building apparatus, comprising: at least one processor and memory;
the memory stores computer-executable instructions;
execution of computer-executable instructions stored by the memory by the at least one processor causes the at least one processor to perform the terrain construction method of any of claims 1-9.
14. A computer-readable storage medium having computer-executable instructions stored thereon which, when executed by a processor, implement the terrain construction method of any of claims 1-9.
CN202010288730.1A 2020-04-14 2020-04-14 Terrain construction method, device and equipment Active CN111508054B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010288730.1A CN111508054B (en) 2020-04-14 2020-04-14 Terrain construction method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010288730.1A CN111508054B (en) 2020-04-14 2020-04-14 Terrain construction method, device and equipment

Publications (2)

Publication Number Publication Date
CN111508054A true CN111508054A (en) 2020-08-07
CN111508054B CN111508054B (en) 2023-08-08

Family

ID=71864617

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010288730.1A Active CN111508054B (en) 2020-04-14 2020-04-14 Terrain construction method, device and equipment

Country Status (1)

Country Link
CN (1) CN111508054B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112190948A (en) * 2020-10-15 2021-01-08 网易(杭州)网络有限公司 Game map generation method and device, electronic equipment and storage medium
CN114677482A (en) * 2020-12-24 2022-06-28 广州博冠信息科技有限公司 Terrain construction method and equipment
CN115690346A (en) * 2022-11-14 2023-02-03 北京世冠金洋科技发展有限公司 Three-dimensional terrain generation method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101950435A (en) * 2010-09-27 2011-01-19 北京师范大学 Navigation-based method for generating interactive non-blocking three-dimensional topographic map
CN109453519A (en) * 2018-11-09 2019-03-12 网易(杭州)网络有限公司 A kind of creation method and device of landform
CN109671162A (en) * 2018-12-12 2019-04-23 北京像素软件科技股份有限公司 Terrain editor method and device
CN109925716A (en) * 2019-04-12 2019-06-25 网易(杭州)网络有限公司 Vertex method for reconstructing, device, processor and the terminal of landform cutting

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101950435A (en) * 2010-09-27 2011-01-19 北京师范大学 Navigation-based method for generating interactive non-blocking three-dimensional topographic map
CN109453519A (en) * 2018-11-09 2019-03-12 网易(杭州)网络有限公司 A kind of creation method and device of landform
CN109671162A (en) * 2018-12-12 2019-04-23 北京像素软件科技股份有限公司 Terrain editor method and device
CN109925716A (en) * 2019-04-12 2019-06-25 网易(杭州)网络有限公司 Vertex method for reconstructing, device, processor and the terminal of landform cutting

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112190948A (en) * 2020-10-15 2021-01-08 网易(杭州)网络有限公司 Game map generation method and device, electronic equipment and storage medium
CN112190948B (en) * 2020-10-15 2024-03-22 网易(杭州)网络有限公司 Game map generation method and device, electronic equipment and storage medium
CN114677482A (en) * 2020-12-24 2022-06-28 广州博冠信息科技有限公司 Terrain construction method and equipment
CN114677482B (en) * 2020-12-24 2022-12-20 广州博冠信息科技有限公司 Terrain construction method and equipment
CN115690346A (en) * 2022-11-14 2023-02-03 北京世冠金洋科技发展有限公司 Three-dimensional terrain generation method and device
CN115690346B (en) * 2022-11-14 2023-08-08 北京世冠金洋科技发展有限公司 Three-dimensional terrain generation method and device

Also Published As

Publication number Publication date
CN111508054B (en) 2023-08-08

Similar Documents

Publication Publication Date Title
CN111508054B (en) Terrain construction method, device and equipment
US10424112B2 (en) Mesh boundary smoothing
CN106251391A (en) Divided method
CN110665232A (en) Rendering method, device and equipment of ground surface in game and storage medium
CN109816749B (en) Map symbol filling method and device, computer equipment and storage medium
CN116051708A (en) Three-dimensional scene lightweight model rendering method, equipment, device and storage medium
CN115222806B (en) Polygon processing method, device, equipment and computer readable storage medium
CN116071519B (en) Image processing method and device for generating grid model based on harmonic mapping
CN109697748B (en) Model compression processing method, model mapping processing method, model compression processing device, and storage medium
JP6294700B2 (en) Image processing apparatus and image processing method
CN115546455B (en) Three-dimensional building model singulation method, device and storage medium
CN107945273B (en) Processing method and device of terrain grid, storage medium and terminal
US10043291B2 (en) Image synthesis
JPH0636013A (en) Method and device for generating topographic data
CN114119925B (en) Game image modeling method and device and electronic equipment
CN114677482B (en) Terrain construction method and equipment
CN111729303B (en) Large map baking and cutting method and restoration method
KR102531766B1 (en) Method and Apparatus for Segmenting Density-based Tetrahedron Model for Level-Of-Detail Generation
CN117058347A (en) Blueprint generation method and device of model and electronic equipment
CN109035186B (en) Terrain non-feature area synthesis method and device based on parallel random sampling and propagation and electronic equipment
CN116385618A (en) Vegetation rendering method and device, storage medium and electronic equipment
CN116402932A (en) Rendering method and device of terrain model, electronic equipment and readable storage medium
CN114272609A (en) Scene terrain generation method and device, storage medium and electronic device
CN115375865A (en) Terrain map processing method and device, electronic equipment and storage medium
CN115908745A (en) Terrace generation method and device in virtual scene and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant