CN112634381B - Method, device and medium for generating random map in game - Google Patents
Method, device and medium for generating random map in game Download PDFInfo
- Publication number
- CN112634381B CN112634381B CN202011518710.5A CN202011518710A CN112634381B CN 112634381 B CN112634381 B CN 112634381B CN 202011518710 A CN202011518710 A CN 202011518710A CN 112634381 B CN112634381 B CN 112634381B
- Authority
- CN
- China
- Prior art keywords
- value
- pixel
- map
- offset
- original
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 29
- 238000010586 diagram Methods 0.000 claims description 61
- 238000013507 mapping Methods 0.000 claims description 50
- 238000004364 calculation method Methods 0.000 claims description 28
- 238000003491 array Methods 0.000 claims description 12
- 239000003086 colorant Substances 0.000 claims description 11
- 238000005070 sampling Methods 0.000 claims description 8
- 238000012545 processing Methods 0.000 claims description 5
- 238000012876 topography Methods 0.000 claims description 4
- 230000000694 effects Effects 0.000 abstract description 5
- 239000003550 marker Substances 0.000 description 21
- 230000003252 repetitive effect Effects 0.000 description 4
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 101100400452 Caenorhabditis elegans map-2 gene Proteins 0.000 description 1
- 101150064138 MAP1 gene Proteins 0.000 description 1
- 238000011161 development Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/001—Texturing; Colouring; Generation of texture or colour
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30204—Marker
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Processing Or Creating Images (AREA)
Abstract
The invention relates to a method, a device, a readable storage medium and a computer software program product for generating random map maps in games, which provide a small amount of original map, then create an initial control map, create a control map conforming to the terrain features by using terrain marking data, endow different initial marking values to different characteristic areas, and better keep the regional characteristics such as the appearance of the area by adopting corresponding map groups in the corresponding sections of the characteristic areas. Finally, the initial map is mixed by using the control map to form the target map. The random mode makes the fine arts personnel need not provide a large amount of non-repeated maps, and a small amount of maps can realize that non-repeated effect picture mixes and brought bigger operating space for fine arts, can produce richer effect.
Description
Technical Field
The present invention relates to the field of computers, and in particular, to a method and apparatus for generating random map in a game, a readable storage medium, and a computer software program product.
Background
Open world large maps are one of the popular game components today, and many open world generation is randomly generated to reduce the heavy amount of tasks required to customize large maps.
For game performance, the map performance is an indispensable component, and for random large-scale maps, a small number of maps can lead to strong repetitive feeling of scenes, so that the problem that art provides more maps is solved, but the problem can bring great repetitive workload to art staff, influence the development efficiency of games, and even if a large number of maps exist, the problem that the same map continuously appears at random is likely to occur, so that a more obvious repetitive phenomenon is brought.
In view of the above, the present inventors have made an in-depth conception for the problems of the map mapping described above, and have made the present invention.
Disclosure of Invention
The invention aims to provide a method, a device, a readable storage medium and a computer software program product for generating a map with a medium speed record in a game, so as to generate a large random map by using a small amount of maps and solve the problem of repetitive feeling caused by the small amount of maps.
In order to achieve the above purpose, the invention adopts the following technical scheme:
a method for generating random map in game includes
An initial control diagram creation step; creating an initial control chart, and setting RGBA channel values corresponding to the colors of each pixel in initial control, wherein the number of the initial control chart creation is 1/4 of that of the initial mapping;
For each initial control graph, the following steps are performed to generate a control graph:
a pixel mark value calculating step; calculating coordinate values of pixels of the initial control diagram in the terrain according to the length-width ratio of the initial control diagram to the terrain grid, and then solving pixel mark values of the pixels;
a pixel weight list calculation step; for each pixel in the initial control diagram, adding an offset value to the pixel mark value to obtain an offset pixel mark value, determining the interval in which the offset pixel mark value is positioned according to the offset pixel mark value, setting weights, and constructing a weight list of the pixel;
A control chart generating step; taking the weight in the pixel weight list as the values of four channels of RGBA, constructing the pixel value, and obtaining a control chart;
Map generation step; and mixing the control map generated by the steps with the original map to form the map.
In the pixel weight list calculation step, the set weights are specifically as follows:
If the offset pixel marking value is in a marking value interval set by a certain original mapping, marking the weight of the corresponding original mapping subscript as 1, and representing that the point samples the original mapping corresponding to the interval;
If the offset pixel mark value is lower than the lowest mark value of the first original map, marking the first original map weight as 1, and representing that the point lower than the lowest mark value of all the original maps samples the first map; if the pixel marking value is higher than the highest value of the highest interval, marking the weight of the last original mapping as 1, and representing sampling the last original mapping;
If the offset pixel mark value is between the mark value intervals of two original maps and is larger than the highest value of the previous mark value interval and smaller than the lowest value of the next mark value interval, determining a mixing proportion according to the three values of the highest value of the previous mark value interval, the offset pixel mark value and the lowest value of the next mark value interval, obtaining the weight of the two original maps, representing that the point samples the two maps and mixing the two maps according to a certain proportion.
In the step of calculating the pixel weight list, if the offset pixel mark value is between the mark value intervals of two original maps, the weights of the two original maps are calculated as follows:
the weights of the next original map are: (pixel offset marker value-highest value of last interval)/the marker value;
the weight of the previous original map is: 1-the weight of the next original map.
The method further comprises a weight array creation step, wherein the length of the weight array is the number of pixels of an initial control chart; the number of the weight arrays is four times of the number of the original maps and corresponds to four channels of the pixel colors of the original maps;
the weight array is used for storing the weight values of the pixels in the pixel weight list calculation step.
In the pixel weight list calculating step, the offset value is calculated as follows:
Calculating an initial noise value by using a Berlin function, and obtaining an actual noise value after processing; the actual noise value is multiplied by the offset coefficient to obtain an offset value.
The offset coefficient comprises a maximum offset coefficient and a minimum offset coefficient; the offset value is calculated as follows:
If the actual noise value is smaller than 0, multiplying the minimum offset coefficient to obtain an offset value; if the actual noise value is greater than 0, multiplying the actual noise value by the maximum offset coefficient to obtain an offset value.
In the pixel mark value calculating step, the pixel mark value is calculated as follows:
First, based on the coordinates h (x, y) of the pixel map to the topography in the initial control map, calculating the lower left grid point h0 (i, j) of the point h, the upper right grid point h1 (iCeil, jCeil), and from the coordinates of the above two points, the upper left grid point h2 (i, jCeil), the lower right grid point h3 (iCeil, j) can be obtained; where i=floor (x), j=floor (y), iCeil =ceil (x),
JCeil = ceil (j); floor represents a rounding down, referring to the largest integer not greater than this value; ceil represents an upward rounding, and refers to a minimum integer not less than this value;
Then, the terrain marking values corresponding to the four points h0, h1, h2 and h3 are obtained;
Finally, the marking value of the point h obtained by bilinear interpolation according to the four surrounding points h0, h1, h2 and h3 is the pixel marking value of the initial control diagram.
A random map generation device in a game comprises
The initial control diagram creation module is used for creating an initial control diagram and setting RGBA channel values corresponding to the colors of each pixel in initial control, wherein the number of the initial control diagram creation is 1/4 of that of the initial map;
The control diagram generation module comprises a pixel mark value calculation unit, a pixel weight list calculation unit and a control diagram generation unit;
the pixel mark value calculating unit is used for calculating coordinate values of pixels of the initial control diagram in the terrain according to the length-width ratio of the initial control diagram to the terrain grid, and solving pixel mark values of the pixels;
The pixel weight list calculation unit is used for adding an offset value to each pixel marking value of the initial control diagram to obtain an offset pixel marking value, determining the interval where the offset pixel marking value is located according to the offset pixel marking value, setting weights and constructing a weight list of the pixels;
The control diagram generating unit is used for constructing the pixel value by taking the weights in the pixel weight list as the values of four RGBA channels to obtain a control diagram;
And the map generation module is used for mixing the generated control maps with the original map to form the map.
The pixel weight list calculation unit sets weights as follows:
If the offset pixel marking value is in a marking value interval set by a certain original mapping, marking the weight of the corresponding original mapping subscript as 1, and representing that the point samples the original mapping corresponding to the interval;
If the offset pixel mark value is lower than the lowest mark value of the first original map, marking the first original map weight as 1, and representing that the point lower than the lowest mark value of all the original maps samples the first map; if the pixel marking value is higher than the highest value of the highest interval, marking the weight of the last original mapping as 1, and representing sampling the last original mapping;
If the offset pixel mark value is between the mark value intervals of two original maps and is larger than the highest value of the previous mark value interval and smaller than the lowest value of the next mark value interval, determining a mixing proportion according to the three values of the highest value of the previous mark value interval, the offset pixel mark value and the lowest value of the next mark value interval, obtaining the weight of the two original maps, representing that the point samples the two maps and mixing the two maps according to a certain proportion.
When the pixel weight list calculating unit is used for calculating the weights, if the offset pixel mark value is between the mark value intervals of two original maps, the weights of the two original maps are calculated as follows:
the weights of the next original map are: (pixel offset marker value-highest value of last interval)/the marker value;
the weight of the previous original map is: 1-the weight of the next original map.
The apparatus further comprises a weight array creation module for creating a weight array for storing weight values of pixels in the pixel weight list calculation step;
The length of the weight array is the number of pixels of an initial control chart; the number of the weight arrays is four times of the number of the original maps and corresponds to four channels of the pixel colors of the original maps.
The pixel weight list calculation unit calculates the offset value as follows:
Calculating an initial noise value by using a Berlin function, and obtaining an actual noise value after processing; the actual noise value is multiplied by the offset coefficient to obtain an offset value.
The offset coefficient comprises a maximum offset coefficient and a minimum offset coefficient; the pixel weight list calculating unit calculates an offset value as follows: if the actual noise value is smaller than 0, multiplying the minimum offset coefficient to obtain an offset value; if the actual noise value is greater than 0, multiplying the actual noise value by the maximum offset coefficient to obtain an offset value.
The pixel mark value calculating unit is used for calculating a pixel mark value, and specifically comprises the following steps:
First, based on the coordinates h (x, y) of the pixel map to the topography in the initial control map, calculating the lower left grid point h0 (i, j) of the point h, the upper right grid point h1 (iCeil, jCeil), and from the coordinates of the above two points, the upper left grid point h2 (i, jCeil), the lower right grid point h3 (iCeil, j) can be obtained; where i=floor (x), j=floor (y), iCeil =ceil (x),
JCeil = ceil (j); floor represents a rounding down, referring to the largest integer not greater than this value; ceil represents an upward rounding, and refers to a minimum integer not less than this value;
Then, the terrain marking values corresponding to the four points h0, h1, h2 and h3 are obtained;
Finally, the marking value of the point h obtained by bilinear interpolation according to the four surrounding points h0, h1, h2 and h3 is the pixel marking value of the initial control diagram.
A computer readable storage medium having instructions stored therein, which when executed on a terminal device, cause the terminal device to perform a method of generating a random map as described above.
A computer software program product which, when run on a terminal device, causes the terminal device to perform a method of generating a random map.
After the scheme is adopted, the original map is adopted and combined with the topographic marker data to generate the control map in the form of the section, and then the generated control map is mixed with the original map to generate the final map. The random mode makes the fine arts personnel need not provide a large amount of non-repeated maps, and a small amount of maps can realize that non-repeated effect picture mixes and brought bigger operating space for fine arts, can produce richer effect. Moreover, since the generation of the control chart is related to the topographic marker data, a control chart conforming to the topographic features can be created; different initial marking values are given to different characteristic areas, and corresponding mapping groups are adopted in corresponding sections of the characteristic areas, so that the regional characteristics such as the appearance of the areas can be better reserved.
Drawings
FIG. 1 is a schematic diagram of the calculation of the marker values of an initial control chart;
Fig. 2 is a schematic diagram of weight setting.
Detailed Description
The invention discloses a method for generating random map in a game, which comprises the following steps:
Step 1, providing an original map;
The original map is provided by an artist staff, and the original map comprises a plurality of groups of maps, and each group of maps consists of a diffuse reflection map and a corresponding normal map. In practice, the art staff may provide a small number of original maps, and in the present embodiment, the original maps provided by the art staff include 8 groups of maps.
Step 2, generating a control chart;
And 2.1, creating initial control charts, creating 1/4 of the original charts, and setting RGBA channel values corresponding to the color values of all pixels in the initial control charts.
In the embodiment of the invention, two initial control charts are required to be created, and the set RGBA channel values are all 1000.
And 2.2, calculating pixel marking values of the initial control diagrams for each initial control diagram, and generating the control diagram by using the marking values. The method comprises the following steps:
And 2.21, acquiring the length w and the width h of the terrain grid, calculating the mark values of all points of the terrain, and distinguishing the mapping layer where a certain point in the terrain is located by using the mark value of the certain point in the terrain for mixing mapping. In the present invention, the method for calculating the mark value of the point in the terrain is not limited.
Step 2.22, calculating the proportion of the transverse axis to the longitudinal axis according to the length cw and the width ch of the control diagram and the length and the width of the terrain grid respectively; wherein, the horizontal axis proportion r0=w/cw, and the vertical axis proportion r1=h/ch; the scale of the horizontal and vertical axes is used to calculate control map data from the grid data.
Step 2.23, for each pixel point in the control chart, obtaining coordinates (x, y) of the pixel point in the map according to the ratio of the position (ci, cj) of the pixel point in the control chart to the corresponding coordinate axis, wherein x=r0/2+r0 ci, and y=r1/2+r1 cj; and then calculating the map mark value of the pixel point.
As shown in fig. 1, in the present embodiment, the map mark value of each pixel point in the control map is calculated as follows:
First, according to the coordinate point h (x, y) of the pixel point mapping in the control chart to the map, calculating the lower left grid point h0 (i, j) of the point h, the upper right grid point h1 (iCeil, jCeil), the upper left grid point h2 (i, jCeil) and the lower right grid point h3 (iCeil, j) can be obtained from the coordinates of the two points; where i=floor (x), j=floor (y), iCeil =ceil (x), jCeil =ceil (j); floor represents a rounding down, referring to the largest integer not greater than this value; ceil represents an upward rounding and refers to the smallest integer that is not less than this value.
Then, map marker values corresponding to the four points h0, h1, h2, h3 are acquired.
Finally, obtaining a marking value of the point h according to bilinear interpolation of the four surrounding points h0, h1, h2 and h3, namely the pixel marking value of the initial control diagram.
And 2.3, creating weight arrays, wherein the number of the arrays is four times of the number of the map groups, and the number of the arrays corresponds to four channels of the pixel colors of the control map. And each array length is the number of pixels of the initial control map.
The weight array is mainly used for storing weight values of the control diagrams generated below, so that a worker can intuitively know the relation between the generated control diagrams and the terrain, and the worker can conveniently carry out feedback adjustment related parameter setting.
In the example, 8 original maps are used, 2 control maps and 8 weight arrays are needed to be generated, and the values in the first four arrays respectively correspond to the values of four channels of each pixel of the first control map and to the mixed weights of the first four original maps; the values in the last four arrays correspond to the values of the four channels of each pixel of the second control chart respectively, and correspond to the mixing weights of the last four original chartlets. The function of the weights is to mark which map is sampled or which maps are mixed in what scale.
And 2.4, calculating a pixel weight list of the position for each pixel point marking value of each control chart. The calculation method is as follows:
Step 2.41, for each pixel, calculating an initial noise value by using a Berlin function according to the position (ci, cj) of the pixel in the control chart, wherein the value is between 0 and 1, adjusting the value to be between-1 and 1, and obtaining an actual noise value in a mode of (noise value-0.5) x 2.
Step 2.42, multiplying the actual noise value by a certain coefficient to obtain a mark value offset value, and adding the offset value to the original mark value to obtain a mark value after offset;
The following scheme is adopted in this example: calculating an actual offset value according to the size of the actual noise value according to the configured maximum offset coefficient and minimum offset coefficient of the noise: if the noise value is smaller than 0, multiplying the minimum offset coefficient to obtain an offset value; if the noise value is greater than 0, multiplying the noise value by the maximum offset coefficient to obtain an offset value. The example of the patent calculates two times of noise, calculates offset values by separating two noise values, and adds the two offset values to the original mark value respectively to obtain a final mark value.
In the embodiment, an offset value mode is adopted in the generation process of the control chart, and the maximum offset value and the minimum offset value are combined, so that the influence of noise on the pixel mark value is effectively controlled.
Step 2.43, obtaining a marker value interval where the pixel is located according to the marker value after the pixel is shifted, setting weights according to the marker value interval, and referring to fig. 2, specifically describing the following steps:
If the offset pixel marking value is in a marking value interval set by a certain original mapping, marking the weight of the corresponding original mapping subscript as 1, and representing that the point samples the original mapping corresponding to the interval;
If the offset pixel mark value is lower than the lowest mark value of the first original map, marking the first original map weight as 1, and representing that the point lower than the lowest mark value of all the original maps samples the first map; if the pixel marking value is higher than the highest value of the highest interval, marking the weight of the last original mapping as 1, and representing sampling the last original mapping;
If the offset pixel mark value is between the mark value intervals of two original maps and is larger than the highest value of the previous mark value interval and smaller than the lowest value of the next mark value interval, determining a mixing proportion according to the three values of the highest value of the previous mark value interval, the offset pixel mark value and the lowest value of the next mark value interval, obtaining the weight of the two original maps, representing that the point samples the two maps and mixing the two maps according to a certain proportion.
In this embodiment, the weights of the two original maps are calculated as follows:
The weights of the next original map are: (pixel offset marker value-highest value of last interval)/the marker value; the weight of the previous original map is: 1-the weight of the next original map.
Step 2.44, obtaining the mixed weights of all the maps at the pixel point according to the step 2.43, and constructing a weight list of the pixel point, wherein each value in the list corresponds to the mixed weight of a certain map. The order of the mapping is consistent for the weight list of all pixels. And simultaneously, storing the mixed weights of all the maps corresponding to the pixel points in the corresponding positions of the corresponding weight arrays in sequence.
And 2.5, constructing pixels corresponding to the positions of the control diagram according to the pixel weight list and sequentially serving as values of four channels RGBA, thereby obtaining the control diagram.
As shown in fig. 2, if the mark value is within a certain interval, the corresponding map group of the interval is adopted, if the mark value is between two intervals, the corresponding original map groups of two adjacent intervals are mixed, the mixing ratio of the original map 1 is the difference value 1/the difference value of the mark value, and the mixing ratio of the original map 2 is the difference value 2/the difference value of the mark value.
And 3, mixing the original maps by using the control map to form a target map.
In this embodiment, the mixing method is as follows: a certain mark value interval is assigned to each group of mapping in the terrain, the mark value intervals corresponding to the mapping groups are sequentially increased from front to back, and each interval is not overlapped with each other; and for each pixel of the mixed map, calculating the final color value of the pixel according to the value of each channel of the pixel in the corresponding control map and the corresponding map group of the channel, thereby obtaining the final mixed map.
In the method, the original map is adopted and combined with the topographic marker data to generate the control map in the form of a section, and then the generated control map is mixed with the original map to generate the final map. Therefore, the use amount of the original mapping can be reduced, and the repeated sense problem caused by a small amount of mapping is effectively avoided. Moreover, because the generation of the control diagram is related to the topographic marker data, the control diagram conforming to the topographic features can be created, for example, different characteristic areas are given different initial marker values, the Berlin noise is utilized for one-time randomization, and the corresponding map groups are adopted in the corresponding sections of the characteristic areas, so that the regional features such as the appearance of the areas can be better reserved.
In addition, the invention can conveniently derive the control diagram generated in the previous step by recording the weights in the control diagram generation process and storing the weights in the weight array, and compare the control diagram with the actual terrain effect, so that staff can more intuitively see the influence of the control diagram on the terrain map, and provide reference for possible subsequent modification. In the practical application process, if a comparison reference is not needed, the weight can be not recorded, i.e. the weight array is not needed to be set.
Based on the same inventive concept, the invention also discloses a device for generating the random map in the game, which comprises an initial control map creation module, a control map generation module and a map generation module.
The initial control diagram creation module is used for creating an initial control diagram, setting RGBA channel values corresponding to the colors of each pixel in initial control, and the number of the initial control diagram creation is 1/4 of that of the initial map.
The control diagram generation module comprises a pixel marking value calculation unit, a pixel weight list calculation unit and a control diagram generation unit.
The pixel mark value calculating unit is used for calculating coordinate values of pixels of the initial control diagram in the terrain according to the length-width ratio of the initial control diagram to the terrain grid, and obtaining pixel mark values of the pixels.
Specifically, the pixel mark value calculating unit obtains the length w and the width h of the terrain grid, calculates mark values of all points of the terrain, and uses the mark value of a certain point in the terrain to distinguish the mapping hierarchy where the point is located and to mix the mapping. In the present invention, the method for calculating the mark value of the point in the terrain is not limited.
Then, the pixel mark value calculating unit calculates the proportion of the horizontal axis and the vertical axis according to the length cw, the width ch and the length and the width of the terrain grid of the control chart; wherein, the horizontal axis proportion r0=w/cw, and the vertical axis proportion r1=h/ch; the scale of the horizontal and vertical axes is used to calculate control map data from the grid data.
Finally, for each pixel point in the control chart, the pixel mark value calculating unit obtains the coordinate (x, y) of the pixel point in the map according to the proportion of the position (ci, cj) of the pixel point in the control chart and the corresponding coordinate axis, wherein x=r0/2+r0 x ci, and y=r1/2+r1 x cj; and then calculating the map mark value of the pixel point.
Referring to fig. 1, in the present embodiment, the map mark value of each pixel point in the control map is calculated as follows:
First, according to the coordinate point h (x, y) of the pixel point mapping in the control chart to the map, calculating the lower left grid point h0 (i, j) of the point h, the upper right grid point h1 (iCeil, jCeil), the upper left grid point h2 (i, jCeil) and the lower right grid point h3 (iCeil, j) can be obtained from the coordinates of the two points; where i=floor (x), j=floor (y), iCeil =ceil (x), jCeil =ceil (j); floor represents a rounding down, referring to the largest integer not greater than this value; ceil represents an upward rounding and refers to the smallest integer that is not less than this value.
Then, map marker values corresponding to the four points h0, h1, h2, h3 are acquired.
Finally, obtaining a marking value of the point h according to bilinear interpolation of the four surrounding points h0, h1, h2 and h3, namely the pixel marking value of the initial control diagram.
The pixel weight list calculation unit is used for adding the offset value to each pixel marking value of the initial control diagram to obtain an offset pixel marking value, determining the interval where the offset pixel marking value is located according to the offset pixel marking value, setting weights and constructing a weight list of the pixels.
In this embodiment, the pixel weight list calculation unit calculates the offset value as follows:
Calculating an initial noise value by using a Berlin function, and obtaining an actual noise value after processing; the actual noise value is multiplied by the offset coefficient to obtain an offset value. Further, in the present embodiment, the offset coefficient includes a maximum offset coefficient and a minimum offset coefficient, so the pixel weight list calculation unit calculates the offset value as: if the actual noise value is smaller than 0, multiplying the minimum offset coefficient to obtain an offset value; if the actual noise value is greater than 0, multiplying the actual noise value by the maximum offset coefficient to obtain an offset value.
In the present embodiment, the pixel weight list calculation unit sets weights as follows:
If the offset pixel marking value is in a marking value interval set by a certain original mapping, marking the weight of the corresponding original mapping subscript as 1, and representing that the point samples the original mapping corresponding to the interval;
If the offset pixel mark value is lower than the lowest mark value of the first original map, marking the first original map weight as 1, and representing that the point lower than the lowest mark value of all the original maps samples the first map; if the pixel marking value is higher than the highest value of the highest interval, marking the weight of the last original mapping as 1, and representing sampling the last original mapping;
If the offset pixel mark value is between the mark value intervals of two original maps and is larger than the highest value of the previous mark value interval and smaller than the lowest value of the next mark value interval, determining a mixing proportion according to the three values of the highest value of the previous mark value interval, the offset pixel mark value and the lowest value of the next mark value interval, obtaining the weight of the two original maps, representing that the point samples the two maps and mixing the two maps according to a certain proportion. In this embodiment, the weight of the next original map is: (pixel offset marker value-highest value of last interval)/the marker value; the weight of the previous original map is: 1-the weight of the next original map.
The control diagram generating unit is used for constructing the pixel value by taking the weights in the pixel weight list as the values of four channels RGBA to obtain a control diagram.
And the map generation module is used for mixing the generated control maps with the original map to form the map.
The system further comprises a weight array creation module, a weight array generation module and a pixel weight list calculation module, wherein the weight array creation module is used for creating a weight array, and the weight array is used for storing the weight value of the pixel in the pixel weight list calculation step;
The length of the weight array is the number of pixels of an initial control chart; the number of the weight arrays is four times of the number of the original maps and corresponds to four channels of the pixel colors of the original maps.
Based on the same inventive concept, the invention also discloses a computer readable storage medium, wherein instructions are stored in the computer readable storage medium, which when run on a terminal device, cause the terminal device to execute the random map generation method as described above.
Based on the same inventive concept, the invention also discloses a computer software program product which, when run on a terminal device, causes the terminal device to execute the random map generation method as described above.
In summary, the key point of the invention is that the invention adopts the original map and combines the topographic marker data to generate the control map in the form of interval, and then mixes the generated control map with the original map to generate the final map. Therefore, the use amount of the original mapping can be reduced, and the repeated sense problem caused by a small amount of mapping is effectively avoided. Moreover, since the generation of the control chart is related to the topographic marker data, a control chart conforming to the topographic features can be created; different initial marking values are given to different characteristic areas, berlin noise is utilized for one-time randomization, and corresponding mapping groups are adopted in corresponding sections of the characteristic areas, so that the regional characteristics such as the appearance of the areas can be better reserved.
The foregoing embodiments of the present invention are not intended to limit the technical scope of the present invention, and therefore, any minor modifications, equivalent variations and modifications made to the above embodiments according to the technical principles of the present invention still fall within the scope of the technical proposal of the present invention.
Claims (13)
1. A method for generating random map in a game is characterized in that: comprising
An initial control diagram creation step; creating an initial control chart, and setting RGBA channel values corresponding to the colors of each pixel in the initial control chart, wherein the number of the initial control chart creation is 1/4 of that of the initial chartlet;
For each initial control graph, the following steps are performed to generate a control graph:
a pixel mark value calculating step; calculating coordinate values of pixels of the initial control diagram in the terrain according to the length-width ratio of the initial control diagram to the terrain grid, and then solving pixel mark values of the pixels;
a pixel weight list calculation step; for each pixel in the initial control diagram, adding an offset value to the pixel mark value to obtain an offset pixel mark value, determining the interval in which the offset pixel mark value is positioned according to the offset pixel mark value, setting weights, and constructing a weight list of the pixel;
A control chart generating step; taking the weight in the pixel weight list as the values of four channels of RGBA, constructing the pixel value, and obtaining a control chart;
map generation step; mixing the control map generated in the steps with the original map to form a map;
In the pixel weight list calculation step, the set weights are specifically as follows:
If the offset pixel marking value is in a marking value interval set by a certain original mapping, marking the weight of the corresponding original mapping subscript as 1, and representing that the point samples the original mapping corresponding to the interval;
If the offset pixel mark value is lower than the lowest mark value of the first original map, marking the first original map weight as 1, and sampling the first original map by a point which is lower than the lowest mark value of all the original maps; if the offset pixel marking value is higher than the highest value of the highest interval, marking the weight of the last original mapping as 1, and representing sampling the last original mapping;
If the offset pixel mark value is between the mark value intervals of two original maps and is larger than the highest value of the previous mark value interval and smaller than the lowest value of the next mark value interval, determining a mixing proportion according to the three values of the highest value of the previous mark value interval, the offset pixel mark value and the lowest value of the next mark value interval, obtaining the weight of the two original maps, representing that the point samples the two maps and mixing the two maps according to a certain proportion.
2. The method for generating a random map in a game according to claim 1, wherein: in the step of calculating the pixel weight list, if the offset pixel mark value is between the mark value intervals of two original maps, the weights of the two original maps are calculated as follows:
the weights of the next original map are: (offset pixel flag value-highest value of last interval)/offset pixel flag value;
the weight of the previous original map is: 1-the weight of the next original map.
3. The method for generating a random map in a game according to claim 1, wherein: the method further comprises a weight array creation step, wherein the length of the weight array is the number of pixels of an initial control chart; the number of the weight arrays is four times of the number of the original maps and corresponds to four channels of the pixel colors of the original maps;
the weight array is used for storing the weight values of the pixels in the pixel weight list calculation step.
4. The method for generating a random map in a game according to claim 1, wherein: in the pixel weight list calculating step, the offset value is calculated as follows:
Calculating an initial noise value by using a Berlin function, and obtaining an actual noise value after processing; the actual noise value is multiplied by the offset coefficient to obtain an offset value.
5. The method for generating a random map in a game according to claim 4, wherein: the offset coefficient comprises a maximum offset coefficient and a minimum offset coefficient; the offset value is calculated as follows:
If the actual noise value is smaller than 0, multiplying the minimum offset coefficient to obtain an offset value; if the actual noise value is greater than 0, multiplying the actual noise value by the maximum offset coefficient to obtain an offset value.
6. The method for generating a random map in a game according to claim 1, wherein: in the pixel mark value calculating step, the pixel mark value is calculated as follows:
First, a coordinate point h (x, y) of the pixel in the initial control map mapped to the topography is calculated, a lower left grid point h0 (i, j) of the point h, an upper right grid point h1 (iCeil, jCeil), a lower left grid point h2 (i, jCeil) and a lower right grid point h3 (iCeil, j) can be obtained from the coordinates of the two points; where i=floor (x), j=floor (y), iCeil =ceil (x),
JCeil = ceil (j); floor represents a rounding down, referring to the largest integer not greater than this value; ceil represents an upward rounding, and refers to a minimum integer not less than this value;
Then, the terrain marking values corresponding to the four points h0, h1, h2 and h3 are obtained;
Finally, the marking value of the point h obtained by bilinear interpolation according to the four surrounding points h0, h1, h2 and h3 is the pixel marking value of the initial control diagram.
7. A random map generation device in a game is characterized in that: comprising
The initial control diagram creation module is used for creating an initial control diagram and setting RGBA channel values corresponding to the colors of each pixel in the initial control diagram, wherein the number of the initial control diagram creation is 1/4 of that of the initial map;
The control diagram generation module comprises a pixel mark value calculation unit, a pixel weight list calculation unit and a control diagram generation unit;
the pixel mark value calculating unit is used for calculating coordinate values of pixels of the initial control diagram in the terrain according to the length-width ratio of the initial control diagram to the terrain grid, and solving pixel mark values of the pixels;
The pixel weight list calculation unit is used for adding an offset value to each pixel marking value of the initial control diagram to obtain an offset pixel marking value, determining the interval where the offset pixel marking value is located according to the offset pixel marking value, setting weights and constructing a weight list of the pixels;
The control diagram generating unit is used for constructing the pixel value by taking the weights in the pixel weight list as the values of four RGBA channels to obtain a control diagram;
The map mapping generation module is used for mixing the generated control maps with the original mapping to form map mapping;
the pixel weight list calculation unit sets weights as follows:
If the offset pixel marking value is in a marking value interval set by a certain original mapping, marking the weight of the corresponding original mapping subscript as 1, and representing that the point samples the original mapping corresponding to the interval;
If the offset pixel mark value is lower than the lowest mark value of the first original map, marking the first original map weight as 1, and sampling the first original map by a point which is lower than the lowest mark value of all the original maps; if the offset pixel marking value is higher than the highest value of the highest interval, marking the weight of the last original mapping as 1, and representing sampling the last original mapping;
If the offset pixel mark value is between the mark value intervals of two original maps and is larger than the highest value of the previous mark value interval and smaller than the lowest value of the next mark value interval, determining a mixing proportion according to the three values of the highest value of the previous mark value interval, the offset pixel mark value and the lowest value of the next mark value interval, obtaining the weight of the two original maps, representing that the point samples the two maps and mixing the two maps according to a certain proportion.
8. The apparatus for generating a random map in a game according to claim 7, wherein: when the pixel weight list calculating unit is used for calculating the weights, if the offset pixel mark value is between the mark value intervals of two original maps, the weights of the two original maps are calculated as follows:
the weights of the next original map are: (offset pixel flag value-highest value of last interval)/offset pixel flag value;
the weight of the previous original map is: 1-the weight of the next original map.
9. The apparatus for generating a random map in a game according to claim 7, wherein: the apparatus further comprises a weight array creation module for creating a weight array for storing weight values of pixels in the pixel weight list calculation step;
The length of the weight array is the number of pixels of an initial control chart; the number of the weight arrays is four times of the number of the original maps and corresponds to four channels of the pixel colors of the original maps.
10. The apparatus for generating a random map in a game according to claim 7, wherein: the pixel weight list calculation unit calculates the offset value as follows:
Calculating an initial noise value by using a Berlin function, and obtaining an actual noise value after processing; the actual noise value is multiplied by the offset coefficient to obtain an offset value.
11. The method for generating a random map in a game according to claim 10, wherein: the offset coefficient comprises a maximum offset coefficient and a minimum offset coefficient; the pixel weight list calculating unit calculates an offset value as follows: if the actual noise value is smaller than 0, multiplying the minimum offset coefficient to obtain an offset value; if the actual noise value is greater than 0, multiplying the actual noise value by the maximum offset coefficient to obtain an offset value.
12. The apparatus for generating a random map in a game according to claim 7, wherein: the pixel mark value calculating unit is used for calculating a pixel mark value, and specifically comprises the following steps:
First, a coordinate point h (x, y) of the pixel in the initial control map mapped to the topography is calculated, a lower left grid point h0 (i, j) of the point h, an upper right grid point h1 (iCeil, jCeil), a lower left grid point h2 (i, jCeil) and a lower right grid point h3 (iCeil, j) can be obtained from the coordinates of the two points; where i=floor (x), j=floor (y), iCeil =ceil (x),
JCeil = ceil (j); floor represents a rounding down, referring to the largest integer not greater than this value; ceil represents an upward rounding, and refers to a minimum integer not less than this value;
Then, the terrain marking values corresponding to the four points h0, h1, h2 and h3 are obtained;
Finally, the marking value of the point h obtained by bilinear interpolation according to the four surrounding points h0, h1, h2 and h3 is the pixel marking value of the initial control diagram.
13. A computer-readable storage medium, characterized by: the computer readable storage medium having stored therein instructions which, when run on a terminal device, cause the terminal device to perform the method of generating an in-game random map as claimed in any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011518710.5A CN112634381B (en) | 2020-12-21 | 2020-12-21 | Method, device and medium for generating random map in game |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011518710.5A CN112634381B (en) | 2020-12-21 | 2020-12-21 | Method, device and medium for generating random map in game |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112634381A CN112634381A (en) | 2021-04-09 |
CN112634381B true CN112634381B (en) | 2024-06-11 |
Family
ID=75320355
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011518710.5A Active CN112634381B (en) | 2020-12-21 | 2020-12-21 | Method, device and medium for generating random map in game |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112634381B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2003169208A (en) * | 2001-12-04 | 2003-06-13 | Noritsu Koki Co Ltd | Image processing apparatus |
WO2010046792A1 (en) * | 2008-10-21 | 2010-04-29 | Nxp B.V. | Method of edge anti-aliasing a graphics geometry and a vectorgraphics processor for executing the same |
CN107886552A (en) * | 2016-09-29 | 2018-04-06 | 网易(杭州)网络有限公司 | Stick picture disposing method and apparatus |
CN109663357A (en) * | 2018-12-19 | 2019-04-23 | 北京像素软件科技股份有限公司 | Game special implementation method and device |
CN110717005A (en) * | 2019-10-10 | 2020-01-21 | 支付宝(杭州)信息技术有限公司 | Thermodynamic diagram texture generation method, device and equipment |
CN111696123A (en) * | 2020-06-15 | 2020-09-22 | 荆门汇易佳信息科技有限公司 | Remote sensing image water area segmentation and extraction method based on super-pixel classification and identification |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8068117B2 (en) * | 2005-06-30 | 2011-11-29 | Microsoft Corporation | Parallel texture synthesis by upsampling pixel coordinates |
US9390548B2 (en) * | 2014-06-16 | 2016-07-12 | Sap Se | Three-dimensional volume rendering using an in-memory database |
-
2020
- 2020-12-21 CN CN202011518710.5A patent/CN112634381B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2003169208A (en) * | 2001-12-04 | 2003-06-13 | Noritsu Koki Co Ltd | Image processing apparatus |
WO2010046792A1 (en) * | 2008-10-21 | 2010-04-29 | Nxp B.V. | Method of edge anti-aliasing a graphics geometry and a vectorgraphics processor for executing the same |
CN107886552A (en) * | 2016-09-29 | 2018-04-06 | 网易(杭州)网络有限公司 | Stick picture disposing method and apparatus |
CN109663357A (en) * | 2018-12-19 | 2019-04-23 | 北京像素软件科技股份有限公司 | Game special implementation method and device |
CN110717005A (en) * | 2019-10-10 | 2020-01-21 | 支付宝(杭州)信息技术有限公司 | Thermodynamic diagram texture generation method, device and equipment |
CN111696123A (en) * | 2020-06-15 | 2020-09-22 | 荆门汇易佳信息科技有限公司 | Remote sensing image water area segmentation and extraction method based on super-pixel classification and identification |
Also Published As
Publication number | Publication date |
---|---|
CN112634381A (en) | 2021-04-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
DE60300788T2 (en) | Image with depth of field from Z buffer image data and alpha mixture | |
EP0137108A1 (en) | A raster display system | |
KR20080050279A (en) | A reduction apparatus and method of popping artifacts for multi-level level-of-detail terrains | |
CN111540024A (en) | Model rendering method and device, electronic equipment and storage medium | |
CN112241993B (en) | Game image processing method and device and electronic equipment | |
CN101393649A (en) | Apparatus and method for rendering multi-viewpoint images | |
CN105701855B (en) | Line style map symbol antialiased rendition method based on symbolic construction | |
CN110276816A (en) | Regional color filling method and device, electronic equipment and computer readable storage medium | |
US12045913B2 (en) | Method and apparatus for displaying virtual landscape picture, storage medium, and electronic device | |
Frade et al. | Modelling video games’ landscapes by means of genetic terrain programming-a new approach for improving users’ experience | |
CN105574914A (en) | Manufacturing device and manufacturing method of 3D dynamic scene | |
EP1246124A2 (en) | Image space display method and apparatus | |
CN112634381B (en) | Method, device and medium for generating random map in game | |
GB2105157A (en) | Simulation of a field of view with target and background | |
CN113470169B (en) | Game scene generation method and device, computer equipment and readable storage medium | |
CN110221689A (en) | A kind of space drawing method based on augmented reality | |
CN110930492A (en) | Model rendering method and device, computer readable medium and electronic equipment | |
JP2021111335A (en) | Method, system and medium for generating compressed image | |
CN116681854A (en) | Virtual city generation method and device based on target detection and building reconstruction | |
CN113313798B (en) | Cloud picture manufacturing method and device, storage medium and computer equipment | |
CN114255312A (en) | Processing method and device of vegetation image and electronic equipment | |
CN115035231A (en) | Shadow baking method, shadow baking device, electronic apparatus, and storage medium | |
CN102339310B (en) | Method for generating raster interpolation and device | |
JPH096941A (en) | Three-dimensional topographical data converting device | |
CN118079396A (en) | Method and system for expanding terrain through terrain block |
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 |