CN117292075A - Spherical topography generation method and device, computing equipment and medium - Google Patents

Spherical topography generation method and device, computing equipment and medium Download PDF

Info

Publication number
CN117292075A
CN117292075A CN202311264161.7A CN202311264161A CN117292075A CN 117292075 A CN117292075 A CN 117292075A CN 202311264161 A CN202311264161 A CN 202311264161A CN 117292075 A CN117292075 A CN 117292075A
Authority
CN
China
Prior art keywords
spherical
grid
sphere
terrain
projected
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.)
Pending
Application number
CN202311264161.7A
Other languages
Chinese (zh)
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.)
Zhuhai Kingsoft Digital Network Technology Co Ltd
Original Assignee
Zhuhai Kingsoft Digital Network Technology 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 Zhuhai Kingsoft Digital Network Technology Co Ltd filed Critical Zhuhai Kingsoft Digital Network Technology Co Ltd
Priority to CN202311264161.7A priority Critical patent/CN117292075A/en
Publication of CN117292075A publication Critical patent/CN117292075A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/05Geographic models
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/20Finite element generation, e.g. wire-frame surface description, tesselation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4007Scaling of whole images or parts thereof, e.g. expanding or contracting based on interpolation, e.g. bilinear interpolation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/60Rotation of whole images or parts thereof

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Geometry (AREA)
  • Software Systems (AREA)
  • Computer Graphics (AREA)
  • Remote Sensing (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the invention provides a spherical terrain generation method and device, a computing device and a medium, wherein the spherical terrain generation method comprises the following steps: the sphere is located in the world coordinate system; calculating mapping parameters of the grid map based on the mapping relation; adjusting the grid map based on the mapping parameters to obtain a grid map to be projected, and projecting the grid map to be projected to the sphere of the sphere to obtain a sphere area corresponding to each grid in the grid map to be projected on the sphere; and generating spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area. By the spherical terrain generation method, performance consumption, calculation complexity and storage space occupation can be reduced when the star terrain is generated.

Description

Spherical topography generation method and device, computing equipment and medium
Technical Field
The embodiment of the invention relates to the technical field of scene modeling, in particular to a spherical terrain generation method.
Background
With the rapid development of the field of scene modeling, various terrains are generally generated in a virtual scene in order to simulate the real world.
Currently, the commonly used terrain tools can only generate planar terrain and cannot generate spherical terrain. In order to generate the topography of the sphere, existing star topography solutions attempt to achieve this by generating a grid on the sphere and generating a subdivision based on camera distance.
However, this approach requires constantly adjusting and updating the subdivision level of the grid. Since the range of subdivision is related to the camera position, as the radius of the planet increases, the range of subdivision needs to be recalculated, which may lead to higher performance consumption. In addition, as the size of the planet increases, the range of mesh subdivisions that need to be regenerated increases, further increasing performance and computational complexity, and as the size of the planet increases, also creates significant memory space usage problems.
Therefore, a new spherical topography generation method is needed to reduce performance consumption, reduce computational complexity and reduce storage space occupation when generating a planet topography.
Disclosure of Invention
In view of this, the embodiment of the invention provides a spherical topography generation method. One or more embodiments of the present invention also relate to a spherical topography generating device, a computing device, a computer readable storage medium and a computer program, which solve the technical drawbacks of the prior art.
According to a first aspect of an embodiment of the present invention, there is provided a spherical topography generating method, including:
determining grid patterns with fixed grid quantity, and establishing a mapping relation between the center of the grid patterns and the sphere center of a sphere, wherein the sphere is positioned in a world coordinate system;
calculating mapping parameters of the grid map based on the mapping relation;
adjusting the grid map based on the mapping parameters to obtain a grid map to be projected, and projecting the grid map to be projected to the sphere of the sphere to obtain a sphere area corresponding to each grid in the grid map to be projected on the sphere;
and generating spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area.
According to a second aspect of an embodiment of the present invention, there is provided a spherical topography generating device comprising:
the determining module is configured to determine a grid chart with fixed grid quantity, and establish a mapping relation between the center of the grid chart and the sphere center of a sphere, wherein the sphere is located in a world coordinate system;
a calculation module configured to calculate mapping parameters of the mesh map based on the mapping relationship;
the adjusting module is configured to adjust the grid map based on the mapping parameters to obtain a grid map to be projected, and project the grid map to be projected to the sphere of the sphere to obtain a sphere area corresponding to each grid in the grid map to be projected;
And the generation module is configured to generate spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area.
According to a third aspect of embodiments of the present invention, there is provided a computing device comprising:
a memory and a processor;
the memory is configured to store computer-executable instructions that, when executed by the processor, perform the steps of the spherical terrain generation method described above.
According to a fourth aspect of embodiments of the present invention there is provided a computer readable storage medium storing computer executable instructions which when executed by a processor implement the steps of the above-described spherical topography generation method.
According to a fifth aspect of embodiments of the present invention, there is provided a computer program, wherein the computer program, when executed in a computer, causes the computer to perform the steps of the above-described spherical topography generation method.
According to the embodiment of the invention, the mapping relation between the grid patterns with the fixed grid number and the spheres is established, the number of the grids is not required to be calculated in real time, the play of the grids is not required to be adjusted, the calculated amount is reduced, the performance consumption is reduced, meanwhile, the grid patterns with the fixed grid number are adopted, no matter the size of the spheres is, the grids are not required to be regenerated, and the calculation complexity and the occupation of storage space are reduced.
Drawings
FIG. 1 is a schematic illustration of a protection flow for a spherical topography generation system architecture according to one embodiment of the present invention;
FIG. 2 is a flow chart of a method of spherical terrain generation provided in one embodiment of the present invention;
FIG. 3 is a schematic illustration of a grid pattern provided by one embodiment of the present invention;
FIG. 4 is a schematic illustration showing projection to a sphere through a grid map provided by an embodiment of the present invention;
FIG. 5 is a schematic diagram of an offset calculation provided by one embodiment of the present invention;
FIG. 6 is a schematic illustration of the effect of creating a planet surface topography provided by one embodiment of the present invention;
FIG. 7 is a normal view of a planet surface provided by an embodiment of the present invention;
FIG. 8 is a height view of a planet surface provided by an embodiment of the present invention;
FIG. 9 is a process flow diagram of a method for generating a planet topography, according to one embodiment of the present invention;
FIG. 10 is a process schematic diagram of a method for generating a planet topography according to one embodiment of the present invention;
FIG. 11 is a schematic diagram of a spherical terrain generating device according to an embodiment of the present invention;
FIG. 12 is a block diagram of a computing device provided by one embodiment of the invention.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. The present invention may be embodied in many other forms than those herein described, and those skilled in the art will readily appreciate that the present invention may be similarly embodied without departing from the spirit or essential characteristics thereof, and therefore the present invention is not limited to the specific embodiments disclosed below.
The terminology used in the one or more embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the invention. As used in one or more embodiments of the invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present invention refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that, although the terms first, second, etc. may be used in one or more embodiments of the invention to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first may also be referred to as a second, and similarly, a second may also be referred to as a first, without departing from the scope of one or more embodiments of the invention. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
Furthermore, it should be noted that, the user information (including, but not limited to, user equipment information, user personal information, etc.) and the data (including, but not limited to, data for analysis, stored data, presented data, etc.) according to one or more embodiments of the present invention are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the relevant data is required to comply with relevant laws and regulations and standards of relevant countries and regions, and is provided with corresponding operation entries for the user to select authorization or rejection.
First, terms related to one or more embodiments of the present invention will be explained.
Spherical topography: a modeling technology for simulating the topography features and morphology of spherical objects such as planets, stars, celestial bodies and the like is commonly used for simulating the morphology of the spherical objects. Unlike conventional planar terrain, spherical terrain requires consideration of the curved surface characteristics of the sphere and the variation of the terrain on the sphere.
Grid: in computer graphics and game development, a Mesh (Mesh) is a shape made up of a series of Vertices (Vertices) and Edges (Edges) or Faces (Faces) connecting them. In brief, the mesh is a three-dimensional geometric model formed by polygons, which may be triangles, quadrilaterals, or other polygons. Each vertex defines the position of a point, an edge defines a line segment connecting between the vertices, and a face defines a plane defined by the vertices and the edge.
Subdivision: a technique for modifying a mesh geometry. Subdivision algorithms create finer geometric details or smoother surfaces by segmenting existing edges and faces, adding new vertices and topologies.
Video camera: in scene modeling, a video camera is a virtual camera device used to observe a game scene and render images. It simulates a real world camera and can control the viewing angle and field of view of the observer, determining the image that is ultimately presented on the screen.
Height diagram: also referred to as an elevation map or elevation field, each pixel value of the elevation map representing elevation or elevation information of a corresponding location is a two-dimensional image representing terrain elevation information.
LOD (Level of Detail): i.e., level of detail, refers to the use of different levels of models or textures to present different levels of detail of an object, depending on viewing distance or other conditions, in computer graphics and game development.
perlin noise: i.e., berlin noise, a continuous random noise function used in the field of terrain generation, etc.
FBM (Fractal Brownian Motion): i.e. fractal brownian motion, a technique that generates complex textures or shapes by iteratively superimposing noise functions of multiple frequencies.
Normal map: texture images commonly used in real-time rendering simulate the surface of an object with higher detail and relief by storing surface normal information.
RT (Render Target): an image buffer for storing rendering results, which may be used to display images on a screen, as well as input to other rendering processes.
In the scene design of the virtual world, the engine only provides a planar terrain generating tool, and cannot directly generate spherical terrain. In order to generate spherical topography, one existing solution is to generate a grid on the sphere, and subdivide the grid along with the distance of the camera, so as to finally realize the generation of the spherical topography. This approach requires constant adjustment and updating of the subdivision level of the grid as the camera position changes, while the subdivision range is also dependent on the camera position. When the planet radius is large, the system needs to recalculate the range of subdivision, which may result in higher performance overhead.
Meanwhile, in the existing scheme, the altitude map is adopted for storing the topographic data, but the method is limited by the resolution of the altitude map, and particularly, a large amount of storage space is occupied when large-scale topography is processed. In addition, the existing generated spherical terrain has some defects in terms of terrain details and realism.
In view of the above problems, in the present invention, there is provided a spherical topography generating method, and the present invention relates to a spherical topography generating device, a computing apparatus, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
Referring to fig. 1, fig. 1 shows a schematic diagram of a protection flow of a spherical topography generating system architecture according to an embodiment of the present invention, where the spherical topography generating system includes a client and a server, the client is configured to send an original sphere to be generated into a spherical topography and receive a sphere returned by the server after generating the spherical topography, and the server is configured to determine a grid map, establish a mapping relationship between a center of the grid map and a center of the sphere, calculate mapping parameters of the grid map, adjust the grid map, and generate the spherical topography. Specifically, the server is used for determining grid patterns with fixed grid numbers, and establishing a mapping relation between the center of the grid patterns and the sphere center of a sphere, wherein the sphere is located in a world coordinate system; calculating mapping parameters of the grid map based on the mapping relation; adjusting the grid map based on the mapping parameters to obtain a grid map to be projected, and projecting the grid map to be projected to the sphere of the sphere to obtain a sphere area corresponding to each grid in the grid map to be projected on the sphere; and generating spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area.
According to the spherical terrain generation system, the mapping relation between the grid patterns with the fixed grid number and the spheres is established, the number of the grids does not need to be calculated in real time, the play of the grids is adjusted, the calculated amount is reduced, and therefore the performance consumption is reduced.
Referring to fig. 2, fig. 2 shows a flowchart of a spherical topography generating method according to an embodiment of the present invention, which specifically includes the following steps.
Step 202: and determining a grid map with fixed grid quantity, and establishing a mapping relation between the center of the grid map and the sphere center of a sphere, wherein the sphere is positioned in a world coordinate system.
The grid patterns with fixed grid number are provided with grid patterns with a certain number of grid cells, each grid cell can be adjusted to be the same or different according to actual requirements, the mapping relationship is the corresponding relationship between the center of the grid pattern and the sphere center of the sphere, for example, the mapping relationship can be that the center of the grid pattern and the sphere center of the sphere are overlapped in a world coordinate system, the world coordinate system is a three-dimensional Cartesian coordinate system, and the sphere center of the sphere can be overlapped with the origin of the world coordinate system.
The grid can be used for dividing the spherical area, and referring to fig. 3, fig. 3 is a schematic diagram showing projection to the sphere through a grid diagram according to one embodiment of the present invention, and fig. 3 shows a schematic diagram of projection of the grid to the surface of the sphere in eight cases that (a), (b), (c), (d), (e), (f), (g) and (h) are respectively shown that the plane grid is on the far right side of the sphere center, the plane grid is on the near left side of the sphere center, the three-dimensional grid is on the far right side of the sphere center, the three-dimensional grid is on the near right side of the sphere center, and the upper and lower vertexes of the three-dimensional grid are connected through the sphere center and the three-dimensional grid semi-surrounds the sphere center.
In practical application, firstly, a spherical surface topography generation system places a sphere in a world coordinate system, so that the positions of points on the sphere can be represented by coordinates; secondly, a grid map with fixed grid quantity is created, the center of the grid map is determined, and the mapping relation between the center of the grid map and the sphere center is established.
In a specific embodiment of the present invention, a sphere is taken as a star ball in game development, a grid diagram is taken as a 4*4 grid diagram, and a mapping relationship is taken as an example that the center of the grid diagram and the center of the sphere coincide in a world coordinate system. Firstly, a spherical terrain generating system places a planet in a world coordinate system, so that the positions of points on the planet can be represented by coordinates; next, a 4*4 grid map is created, the center of the 4*4 grid map is determined, and the 4*4 grid map is placed in the world coordinate system, so that the positions of the points on the grid map can be represented by coordinates, and the center of the grid map and the center of the sphere coincide in the world coordinate system.
Further, the origin of the world coordinate system is the sphere center; correspondingly, the determining the grid map with the fixed grid number, and establishing the mapping relation between the center of the grid map and the center of the sphere, comprises the following steps: receiving the grid graph, and carrying out normalization processing on the grid graph; initializing the direction of the grid graph after the normalization processing, so that the normal direction of the grid graph is the same as the direction of a target coordinate axis in the world coordinate system; and establishing a mapping relation between the center of the grid graph and the center of the sphere after initialization.
The target coordinate axis may be a coordinate axis specified in the world coordinate system, for example, a z-axis, and the normalization process is performed on the length data of the grid map.
In practical application, firstly, a spherical terrain generation system normalizes vertexes of the grid map to be within a [ -1,1] interval; secondly, adjusting the position of the grid graph to enable the normal direction of the grid graph to be the same as the direction of a target coordinate axis, wherein the target coordinate axis can be specified according to actual requirements, for example, the direction of a z axis is specified as the target direction; and finally, establishing a mapping relation between the center of the grid graph and the center of the sphere after initialization.
In a specific embodiment of the present invention, referring to fig. 4, first, fig. 4 is a schematic diagram of a mesh graph according to an embodiment of the present invention, where vertices of the mesh graph 4*4 are normalized to be within [ -1,1] intervals, and coordinates of an upper right-most vertex, a lower left-most vertex, and an upper left-most vertex of the mesh graph in a world coordinate system are (1, 0), (1, -1, 0), (-1, 0), respectively; second, the position of the 4*4 grid map is adjusted so that the normal of the 4*4 grid map is oriented in the same direction as the z-axis; finally, a mapping relation is established that the center of the 4*4 grid diagram after the direction adjustment coincides with the sphere center of the planet at the origin of the world coordinate system.
Based on the method, the initialization grid can provide support for the subsequent generation of the spherical area, and meanwhile, the center of the grid diagram corresponds to the sphere center of the sphere through the mapping relation, so that the consistency of coordinates is ensured, the spherical coordinates or the grid coordinates can be conveniently converted into world coordinates when the subsequent operation and rendering are performed on the sphere, and the calculation and rendering process is simplified.
Step 204: and calculating the mapping parameters of the grid map based on the mapping relation.
Wherein the mapping parameter is used for indicating the moving direction and distance of each vertex in the grid chart
In practical application, an algorithm or a formula of the moving direction and the moving distance of each vertex in the grid can be determined according to the mapping relation between the center of the grid graph and the sphere center, and then the moving direction and the moving distance of each vertex in the grid graph, namely the mapping parameter, are calculated by using the determined algorithm or formula. It will be appreciated that the mapping parameters may also be adjusted and controlled as desired.
In a specific embodiment of the present invention, according to the above example, the spherical topography generating system determines an algorithm or a formula of the moving direction and the moving distance of each vertex in the grid according to the mapping relation between the center of the 4*4 grid map and the origin of the world coordinate system where the center of the sphere coincides with the world coordinate system, and then calculates the moving direction and the distance of each vertex in the grid map, that is, the mapping parameter by using the determined algorithm or formula.
In another embodiment of the present invention, along the above example, the user side adjusts and sets the moving direction and the moving distance of each vertex in the 4*4 grid chart according to the related requirements.
Further, the calculating the mapping parameters of the grid map based on the mapping relation further comprises; determining target vertexes in the grid graph based on the mapping relation, wherein the grid graph comprises a plurality of original vertexes, each original vertex corresponds to at least one grid, and the target vertexes are vertexes, corresponding to the original vertexes, of which the number of grids is larger than a preset threshold value; responding to a grid pattern changing request which is input by a user side and contains grid pattern changing parameters, and calculating the displacement of each target vertex based on the grid pattern changing parameters; and determining mapping parameters of the grid map based on the displacement of each target vertex.
The original vertex is an intersection point between line segments in the mesh map, for example, a square mesh unit may correspond to four vertices, and a triangle mesh unit may correspond to three vertices.
In practical application, firstly, in a grid map, a spherical terrain generation system determines target vertexes according to a preset threshold, wherein the target vertexes are vertexes of which the number of grids corresponding to an original vertex is larger than the preset threshold; secondly, when a grid deformation request containing grid deformation parameters input by a user terminal is received, displacement calculation is required to be carried out on the target vertexes according to the parameters; then, calculating the displacement of each target vertex according to the displacement amount and the direction specified in the parameters; and finally, after the displacement of the target vertex is calculated, determining the mapping parameters of the grid graph according to the displacement and the direction.
In a specific embodiment of the present invention, using the above example and taking the target vertex as the vertex corresponding to four grid cells as an example, firstly, in the grid map, the spherical terrain generation system determines the target vertices corresponding to four grid cells as (-0.5,0.5,0), (0,0.5,0), (0.5,0.5,0), (0.5, 0), (0.5, -0.5, 0), (0, -0.5, 0), (-0.5, 0), (0, 0); secondly, when a grid deformation request containing grid deformation parameters input by a user end is received, displacement calculation is needed to be carried out on target vertexes according to the parameters, displacement of each target vertex is calculated, and specifically, the grid deformation parameters and the grid deformation formulas contained in the request are as follows:
Wherein g z G is the z-axis coordinate after the target vertex moves x For the x-axis coordinate before the movement of the target vertex, g y The y-axis coordinate before the movement of the target vertex is defined as a grid deformation parameter, 4 is adjustable according to the requirement, the x-axis coordinate before the movement and the y-axis coordinate after the movement of the target vertex are unchanged, and the original z-axis coordinate of the target vertex is 0, so that the displacement of the target vertex moves towards the positive direction of the z-axis by g z A unit distance;
finally, according to the movement g of each target vertex towards the positive direction of the z axis z The unit distances determine the mapping parameters of the grid map.
Based on the method, deformation and movement of the grid graph are realized, so that the spherical topography can be customized and adjusted according to the requirements of users.
Step 206: and adjusting the grid map based on the mapping parameters to obtain a grid map to be projected, and projecting the grid map to be projected to the sphere of the sphere to obtain a sphere area corresponding to each grid in the grid map to be projected on the sphere.
Wherein the grid pattern to be projected is a grid pattern in which vertexes in the grid pattern move according to a moving direction and a moving distance indicated by mapping parameters, the projection is to emit virtual light by taking a sphere center as a starting point, a projection image is left on the surface of a sphere through the operation of the grid pattern to be projected, and a spherical area is a corresponding area after the grid is projected to the surface of the sphere
In practical application, firstly, for each grid vertex, a spherical terrain generation system determines the moving direction and the moving distance of the grid vertex according to the calculated mapping parameters, and each vertex is moved according to the determined moving direction and moving distance to obtain a grid diagram to be projected, wherein the grid diagram to be projected comprises the adjusted vertex positions; next, the spherical terrain generation system projects a grid pattern to be projected onto the sphere of the sphere such that each vertex is mapped to a corresponding location on the surface of the sphere, each grid in the grid pattern to be projected corresponding to a spherical region on the sphere.
In a specific embodiment of the present invention, taking the above example and taking the mapping parameter as the vertex a to displace by one unit in the z-axis direction as an example, firstly, for each grid vertex, the spherical topography generating system determines that the vertex a needs to displace by one unit in the z-axis direction according to the calculated mapping parameter, and after the vertex a displaces by one unit in the z-axis direction, a grid diagram to be projected is obtained, where the grid diagram to be projected includes the vertex a after displacing by one unit in the z-axis direction; secondly, the spherical terrain generating system projects a grid map to be projected onto the sphere of the planet, so that each vertex is mapped to a corresponding position on the surface of the planet, and each grid in the grid map to be projected corresponds to one spherical area on the sphere of the planet.
Further, the adjusting the grid map based on the mapping parameter to obtain a grid map to be projected includes: responding to the maximum terrain height input by a user side, and calculating the maximum radius of the sphere based on the sphere radius of the sphere and the maximum terrain height, wherein the attribute parameters of the sphere comprise the sphere radius and the maximum radius; calculating an offset of the grid map based on a positional parameter of a camera in the world coordinate system relative to the sphere center, the sphere radius and the maximum radius; and adjusting the grid map based on the mapping parameters and the offset to obtain a grid map to be projected.
The offset is the offset of the whole grid chart.
In practical application, firstly, calculating the maximum radius of the sphere according to the sphere radius and the maximum terrain height of the sphere, wherein the maximum terrain height defines the maximum height variation range of the sphere surface and can be added with the sphere radius to obtain the maximum radius of the sphere; secondly, calculating the offset of the grid graph based on the position parameter of the camera relative to the sphere center in the world coordinate system and the radius and the maximum radius of the sphere, wherein the offset represents the integral offset of the grid graph; and finally, according to the mapping parameters and the offset, adjusting the grid map to obtain the grid map to be projected.
In a specific embodiment of the invention, the example is used along the edge, and the maximum terrain height is taken as the highest peak height, the radius of the sphere is the radius of the planet, the position parameter is the distance and the direction of the camera from the center of the sphere, firstly, the maximum radius of the planet is calculated according to the radius of the planet and the highest peak height, and the maximum peak height and the radius of the planet are added to obtain the maximum radius of the planet; secondly, calculating the overall offset of the grid map based on the distance and the direction from the camera to the center of the sphere and the radius of the planet and the maximum radius, wherein the offset represents the overall offset of the grid map, specifically, referring to fig. 5, fig. 5 is a schematic diagram of offset calculation provided by an embodiment of the present invention, and the formula for calculating the offset is as follows:
wherein A is the position of a camera, B is the position of the center of a planet, C is the highest peak point, AC is tangent to the planet and D, E is the uppermost vertex in the grid, F is the centremost vertex in the grid, phi is the included angle between BC and AB, AB is the distance from the camera to the planet, BD is the radius of the planet, BC is the maximum radius of the planet, and FB is the final calculated offset;
and finally, according to the mapping parameters and the offset FB, adjusting the position of the grid map to obtain the grid map to be projected.
Based on the method, the consistency of the geometric relation between the grid map and the sphere and the consistency of the topographic features are ensured, the proper visual effect related to the surface of the sphere is provided, meanwhile, the maximum radius is considered, and the problem of collision between the camera and the highest part of the topography caused by the maximum radius in the subsequent rendering is avoided.
Further, the adjusting the grid map based on the mapping parameter to obtain a grid map to be projected includes: calculating a rotation matrix of the grid map based on a position parameter of the camera relative to the center of sphere in the world coordinate system and a position parameter of the grid map relative to the center of sphere in the world coordinate system; and adjusting the grid map based on the mapping parameters and the rotation matrix to obtain a grid map to be projected.
In practical application, first, based on the position parameter of the camera relative to the center of the sphere in the world coordinate system and the position parameter of the grid map relative to the center of the sphere in the world coordinate system, the rotation matrix of the grid map is calculated, and the following formula can be referred to:
u=w×v
wherein p is a camera position vector, w is a normalized camera position coordinate, u and v are components of a sphere center to the camera vector on an x axis and a y axis, and R is a rotation matrix;
Secondly, adjusting the grid map by using the mapping parameters and the rotation matrix so as to accurately present the posture and the shape of the grid map under the view angle of the camera; finally, the grid graph after adjustment is the grid graph to be projected.
Based on the method, the grid map is ensured to present the correct posture and shape under the view angle of the camera, and the spherical surface in the view range of the camera is ensured to render the terrain.
Further, the adjusting the grid map based on the mapping parameter and the offset to obtain a grid map to be projected includes: calculating a rotation matrix of the grid map based on a position parameter of the camera relative to the center of sphere in the world coordinate system and a position parameter of the grid map relative to the center of sphere in the world coordinate system; and adjusting the grid map based on the mapping parameters, the offset and the rotation matrix to obtain a grid map to be projected.
In practical application, firstly, calculating the maximum radius of the sphere according to the sphere radius and the maximum terrain height of the sphere, wherein the maximum terrain height defines the maximum height variation range of the sphere surface and can be added with the sphere radius to obtain the maximum radius of the sphere; secondly, calculating the offset of the grid graph based on the position parameter of the camera relative to the sphere center in the world coordinate system and the radius and the maximum radius of the sphere, wherein the offset represents the integral offset of the grid graph; thirdly, calculating a rotation matrix of the grid map based on the position parameters of the camera relative to the sphere center in the world coordinate system and the position parameters of the grid map relative to the sphere center in the world coordinate system, and then adjusting the grid map by using the mapping parameters and the rotation matrix so as to accurately present the posture and the shape of the grid map under the view angle of the camera; finally, the grid graph after adjustment is the grid graph to be projected
Based on this, it is ensured that the grid pattern assumes the correct pose, shape and position under the camera view.
Further, the projecting the grid map to be projected onto the sphere of the sphere to obtain a sphere area corresponding to the sphere of each grid in the grid map to be projected, including: determining a position vector of each vertex in the grid graph to be projected relative to the sphere center, and normalizing the position vector to the sphere center; and calculating projection points of the vertexes in the spherical surface according to the normalized position vector and the radius of the spherical surface, and determining spherical surface areas corresponding to the spherical surface of each grid in the grid graph to be projected according to the projection points.
In practical application, first, for each vertex in the mesh map to be projected, a position vector thereof with respect to the center of the sphere is determined, that is, a vector directed from the center of the sphere to the vertex is calculated; secondly, normalizing the position vector of each vertex; then, calculating a projection point of each vertex on the spherical surface according to the normalized position vector and the radius of the spherical surface, and multiplying the normalized position vector by the radius of the spherical surface to obtain the coordinate of each vertex on the spherical surface; and finally, determining a spherical area corresponding to each grid on the spherical surface in the grid graph to be projected according to the calculated projection points.
Based on this, accurate sphere region information is provided for subsequent sphere rendering, texture mapping, or other sphere related operations.
Step 208: and generating spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area.
Wherein, the three-dimensional terrain function can be a height function, can comprise a definition mode of the terrain features such as mountains, rivers, canyons and the like, and can also be other self-defined functions to express the attribute and the feature of the terrain
In practical application, firstly, a spherical surface topography generation system acquires a three-dimensional topography function corresponding to each spherical surface region on a spherical surface according to the region; secondly, the spherical topography generation system calculates height data on each spherical surface area according to the selected three-dimensional topography function, and the height data can be used for describing the height value or other topography properties of each point on the spherical surface; and finally, the spherical terrain generation system utilizes the calculated height data to generate the terrain on the spherical surface, and the spherical terrain can be rendered and colored according to the height data, for example, the higher terrain is rendered white, so that the spherical terrain has realism and detail. The spherical terrain generation system may also make further adjustments and optimizations to the generated spherical terrain, such as smoothing, adding detail, or adding special effects, as desired.
In a specific embodiment of the present invention, taking the above example and taking a three-dimensional terrain function as an FBM function based on 3D Perlin noise as an example, firstly, a spherical terrain generating system obtains an FBM function based on 3D Perlin noise corresponding to each spherical region on the surface of a planet according to the region; secondly, the spherical terrain generation system calculates height data on each spherical area according to the selected FBM function based on 3D Perlin noise, and the data can be used for describing the height value or other terrain attribute of each point on the surface of the planet; and finally, the spherical terrain generation system utilizes the calculated altitude data to generate the terrain on the surface of the planet, and renders and colors according to the altitude data, for example, higher terrain is rendered white, so that the spherical terrain has realism and detail. Referring to fig. 6, fig. 6 is a schematic diagram showing the effect of generating a planet surface topography according to an embodiment of the present invention.
Further, the three-dimensional topographic function comprises an initial amplitude parameter and an initial frequency parameter; correspondingly, the generating spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area comprises the following steps: obtaining a first intermediate result according to the three-dimensional position coordinates of the spherical terrain to be generated in each spherical area and the three-dimensional terrain function; adjusting the initial amplitude parameter and the initial frequency parameter based on a preset rule to obtain an intermediate amplitude parameter and an intermediate frequency parameter, and obtaining an intermediate three-dimensional terrain function based on the intermediate amplitude parameter and the frequency parameter; carrying out iterative processing on the three-dimensional position coordinates of the spherical terrain to be generated in each spherical area and the intermediate three-dimensional terrain function to obtain a plurality of second intermediate results; and calculating the height coordinate of the spherical terrain to be generated according to the first intermediate result and each second intermediate result, and generating the spherical terrain based on the height coordinate and each spherical area.
In practical application, firstly, for each spherical area, calculating a three-dimensional position coordinate of a spherical terrain to be generated and a corresponding three-dimensional terrain function to obtain a first intermediate result, wherein the process can obtain a height value or a terrain change index corresponding to each position coordinate by substituting the position coordinate into the function; secondly, based on a preset rule, adjusting an initial amplitude parameter and an initial frequency parameter to obtain an intermediate amplitude parameter and an intermediate frequency parameter; thirdly, generating an intermediate three-dimensional terrain function according to the intermediate amplitude parameter and the frequency parameter, and using the intermediate three-dimensional terrain function for subsequent iterative processing; then, carrying out iterative processing on the three-dimensional position coordinates of the spherical terrain to be generated and the intermediate three-dimensional terrain function to obtain a plurality of second intermediate results so as to gradually generate finer terrain information; finally, based on the first intermediate result and each second intermediate result, the height coordinates of the spherical terrain to be generated are calculated. The calculation process may take the first intermediate result as a starting point, combine the second intermediate results to perform weighted calculation to obtain a final altitude coordinate, generate a spherical terrain according to the altitude coordinate and the spherical area, and perform texture mapping, coloring, or other related operations as needed.
In a specific embodiment of the present invention, taking the above example, taking the three-dimensional terrain function as the FBM function based on 3D Perlin noise as an example, the FBM equation is as follows:
wherein N (p) is Perlin noise, ζ i As amplitude parameter lambda i For the frequency parameter, the amplitude parameter and the frequency parameter are adjusted according to a preset rule, wherein the preset rule is as follows:
ξ i =I a ×g i
λ i =I f ×l i
wherein I is a G is the initial amplitude g i For amplitude gain parameter, I f For the initial frequency, l i Is a frequency porosity parameter.
Based on this, the details and features of the terrain are gradually optimized by iterative processing and parameter adjustment to generate a spherical terrain meeting the requirements.
Further, the step of inputting the three-dimensional position coordinates of the spherical terrain to be generated in each spherical area, the initial amplitude parameter and the initial frequency parameter into a three-dimensional terrain function to obtain a first intermediate result, further includes: determining a sharpness scalar for each location in each spherical region, wherein the sharpness scalar is used to describe a rate of change of terrain; obtaining an absolute value function and a complementary function based on the three-dimensional topographic function, wherein the absolute value function is an absolute value function taking result of the three-dimensional topographic function, and the complementary function is a difference function between the absolute value function and 1; and adjusting the terrain sharpness of each position in each spherical area according to the sharpness scalar, the absolute value function, the supplement function and the three-dimensional terrain function.
In practical application, first, for each spherical region position, determining its corresponding sharpness scalar, the sharpness scalar being used to describe the rate of change of the terrain; secondly, calculating an absolute value function and a complementary function according to the three-dimensional topographic function, wherein the absolute value function is a result of taking the absolute value of the three-dimensional topographic function and is used for describing forward change of topography, and the complementary function is a difference function between the three-dimensional topographic function and 1 and is used for describing reverse change of topography; finally, adjusting terrain sharpness based on the sharpness scalar, the absolute value function, the complement function, and the three-dimensional terrain function: the sharpness of the terrain at each location in the spherical areas is adjusted based on the sharpness scalar, the absolute value function, the complement function, and the three-dimensional terrain function.
In a specific embodiment of the present invention, the edge uses the above example and takes the absolute function as the billow Noise (NB) and the complementary function as the ridge Noise (NR) as examples, and first, for each position in the spherical region, the corresponding sharpness scalar S is determined S Wherein S is S ∈[-1,1]The formula for adjusting the terrain sharpness based on the sharpness scalar, billow noise, ridge noise, and Perlin noise is as follows:
N B (p)=|N(p)|
N R (p)=1-N B (p)
wherein N is B (p) is the billow noise, N R (p) is the edge noise, N C (p) is a formula for adjusting the sharpness of terrain based on sharpness scalar, follow noise, ridge noise, and Perlin noise.
Based on this, the rate of change of the terrain can be controlled according to the sharpness scalar, with positive and negative changes of the terrain being adjusted with absolute value functions and supplemental functions to obtain richer and true terrain features.
Further, after the three-dimensional position coordinates of the spherical terrain to be generated in each spherical area, the initial amplitude parameter and the initial frequency parameter are input into a three-dimensional terrain function, a first intermediate result is obtained, the method further comprises: determining gradients and gradient factors of positions in the spherical areas, wherein the gradient factors are used for describing the erosion degree of the gradient to the terrain; and calculating gradient erosion parameters of each position in each spherical surface area according to the gradient and the gradient factor, wherein the gradient erosion parameters are used for participating in the iterative processing together with the intermediate amplitude parameters and the intermediate frequency parameters.
In practical applications, firstly, for each position in the spherical area, determining a corresponding gradient and a gradient factor, wherein the gradient describes the change rate of the terrain at the position, the change rate can be obtained by calculating partial derivatives of position coordinates, the gradient factor is used for describing the erosion degree of the gradient to the terrain, and the model length of the gradient or other indexes can be calculated to measure the erosion degree of the gradient to the terrain; secondly, calculating gradient erosion parameters of each position in each spherical surface area according to the gradient and gradient factors, wherein the calculation process can be combined with the gradient and gradient factors for weighting, can be calculated through other mathematical functions or formulas, and the gradient erosion parameters are used for representing the degree of the terrain eroded by the gradient and can be used for adjusting the terrain in subsequent iterative processing; finally, the calculated gradient erosion parameters and other parameters such as the intermediate amplitude parameters and the intermediate frequency parameters are involved in subsequent iterative processing, and details, shapes and characteristics of terrains can be adjusted by combining the gradient erosion parameters with the other parameters, so that more realistic terrain simulation is realized.
In one embodiment of the invention, along the line of the above example, the grade erosion δs is given by the following equation:
where G (p) represents the gradient of p-point, which can be calculated by the analytical derivative of Perlin noise, and controlled by the grade erosion parameter Es, as shown in the following equation:
based on this, a more realistic, more variable terrain simulation is achieved by calculating, weighting and adjusting the gradient and slope factors.
Further, after the initial amplitude parameter and the initial frequency parameter are adjusted based on the preset rule to obtain an intermediate amplitude parameter and an intermediate frequency parameter, the method further includes: determining the altitude and the altitude factor of each position in each spherical area, wherein the altitude factor is used for describing the erosion degree of altitude to terrain; determining the degree of concavity and a concavity factor of each position in each spherical region, wherein the concavity factor is used for describing the degree of corrosiveness of the concavity degree to the terrain; the intermediate frequency parameter is adjusted based on the altitude, the altitude factor, the degree of dishing, and the dishing factor.
In practical application, firstly, for the position in each spherical area, determining the corresponding altitude and altitude factor, wherein the altitude represents the altitude of the terrain, the altitude factor is obtained through calculation of the coordinate position or other modes, the altitude factor is used for describing the degree of erosion of the terrain by the altitude, and the altitude factor can be calculated according to the change rate of the altitude or other indexes; secondly, for the position in each spherical area, determining the corresponding sinking degree and sinking factor, wherein the sinking degree represents the sinking degree of the terrain relative to the surrounding area, the sinking degree can be measured by comparing the height change rate of the position and the surrounding height, and the sinking factor is used for describing the erosion degree of the sinking degree to the terrain and can be calculated according to the change rate of the sinking degree or other indexes; finally, the intermediate frequency parameter is adjusted according to the altitude, the altitude factor, the dent degree and the dent factor, and the local shape and detail of the terrain can be adjusted according to the altitude, the altitude factor, the dent degree and the dent factor.
In one embodiment of the present invention, ζ is adjusted by the altitude erosion parameter along the above example i The formula is as follows:
wherein sigma i Is of height; adjustment of g by pitting erosion parameters i The formula is as follows:
wherein E is c For the sag factor, ci defines the degree of concavity and convexity of the terrain at the current position, and the formula is as follows:
based on the above, the weighting and adjustment of each factor and the frequency parameter are carried out, so that the more realistic, various and fine terrain generating effect is realized.
Further, after generating the spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area, the method further comprises: determining coordinates of each position according to the spherical topography, and obtaining a height map of the spherical topography based on the coordinates of each position of the spherical topography; and calculating a normal map of the spherical surface terrain based on the altitude map.
In practical application, firstly, determining coordinates of each position on a spherical surface according to the generated spherical surface topography and the information of a spherical surface region; secondly, calculating a height map of the spherical topography on the spherical surface by utilizing the coordinate information of each position of the spherical topography; and finally, calculating a normal map of the spherical surface topography according to the height map.
In one embodiment of the present invention, reference is made to fig. 7, where fig. 7 is a normal map of the surface of a planet according to one embodiment of the present invention. The formula for calculating the height map from the normal map is as follows:
S(i,j)=<1,0,aH(i+1,j)-aH(i-1,j)>
T(i,j)=<1,0,aH(i,j+1)-aH(i,j-1)>
where S (i, j) and T (i, j) are gradient vectors of the two-dimensional height field H (i, j) in the horizontal and vertical directions, S (i, j) represents a gradient vector in the horizontal direction (x-axis), and T (i, j) represents a gradient vector in the vertical direction (y-axis).
Referring to fig. 8, fig. 8 is a height diagram of a planet surface according to an embodiment of the present invention, wherein A, B, C, D in fig. 8 are respectively different colors, and represent that the corresponding positions of the areas are in different height intervals.
Based on this, the normal map and the altitude map may be used in further visualization, rendering, or other terrain analysis applications.
According to the embodiment of the invention, the mapping relation between the grid patterns with the fixed grid number and the spheres is established, the number of the grids is not required to be calculated in real time, the play of the grids is not required to be adjusted, the calculated amount is reduced, the performance consumption is reduced, meanwhile, the grid patterns with the fixed grid number are adopted, no matter the size of the spheres is, the grids are not required to be regenerated, and the calculation complexity and the occupation of storage space are reduced.
The spherical topography generation method provided by the invention is further described below by taking an application of the spherical topography generation method in game development star topography generation as an example with reference to fig. 2. Fig. 9 is a flowchart of a processing procedure of a star topography generating method according to an embodiment of the present invention, which specifically includes the following steps.
Step 902: a fixed subdivision grid patch is input and adjusted.
In one implementation, a fixed subdivision grid patch is input, the central coordinate of the grid patch is normalized to the world space origin, the length x and the width y of the grid patch are controlled to be within the [ -1,1] interval, and the normal of the plane faces the z direction. Formula for applying vertex position
The vertex position is adjusted so as to be shifted in the z direction near the center point, resulting in an image similar to a two-dimensional gaussian function, as shown with reference to (a) in fig. 10. Where the larger n the greater the z-direction offset peak with center spread, the best is tested for n=4. The specific process is described with reference to the above embodiments, and will not be repeated here.
Step 904: the subdivided mesh patches are offset.
In one implementation, the offset distance of the subdivided mesh facets is calculated from the maximum radius of the planet (radius plus peak), the radius of the planet itself, and the camera-to-center distance, with the offset result being shown with reference to (b) in fig. 10. The specific process is described with reference to the above embodiments, and will not be repeated here.
Step 906: the subdivided mesh patches are rotated.
In one implementation, the z direction of the local space of the plane is always directed to the camera position by calculating the rotation matrix, and finally when the plane is completely unfolded into a hemispherical sphere, only one hemisphere directed to the camera needs to be rendered, no grid is needed for the hemispherical sphere on the back of the planet, and the visual effect of the whole planet can be realized only by the hemisphere, and the rotation result is shown in (c) in fig. 10. The specific process is described with reference to the above embodiments, and will not be repeated here.
Step 908: the grid vertex vector is normalized and then multiplied by the radius of the planet to be projected on the sphere.
In one implementation, the grid vertex vector is normalized and then multiplied by the radius of the planet to be projected onto the sphere, and as the offset term is related to the distance of the camera, the size of the offset term affects the density of the last vertex projected onto the sphere near the center, at this time, the effect that when the camera is far from the planet, the grid is uniformly distributed to the whole hemisphere, and when the camera is near the earth surface, the density of the grid toward the center increases is achieved, and the projection result is shown in (d) in fig. 10. The specific process is described with reference to the above embodiments, and will not be repeated here.
Step 910: terrain is generated based on Berlin noise and the FBM method.
The specific process of generating the terrain based on the berlin noise and the FBM method is described with reference to the above embodiments, and will not be repeated here.
Step 912: topography sharpness adjustment topography is defined.
In one implementation, the sharpness of the terrain is defined by two well-known noises, the first being the billow Noise (NB), given by the absolute value of the noise function, providing a wavy feature. The second is the ridge Noise (NR), which is derived from the complement of the billow noise, setting a sharp pattern. A sharpness scalar Ss e < -1,1 > is used to linearly interpolate between the Perlin noise, the billow noise, and the ridge noise. The interpolation process is described with reference to the above embodiments, and will not be described here again.
Step 914: elevation erosion parameters are defined to adjust terrain.
In one implementation, altitude erosion causes details of noise to disappear rapidly at a lower level. Altitude erosion may be introduced in fBm, with gradual attenuation of amplitude based on total height and altitude factor, the specific process being described with reference to the above embodiments and not repeated here.
Step 916: the grade erosion parameters are defined to adjust the terrain.
In one implementation, the grade erosion parameter is directly dependent on the degree of terrain steepness. The terrain gradient may be obtained by its derivative. The specific process is described with reference to the above embodiments, and will not be repeated here.
Step 918: defining the concave erosion parameter to adjust the topography.
In one implementation, the concave surface tends to deposit more easily and the concave erosion will make the terrain smoother depending on the degree of concavity of the terrain. The specific process is described with reference to the above embodiments, and will not be repeated here.
Step 920: a topographical surface normal is generated.
The process of generating the normal is described with reference to the above embodiments, and will not be described here again.
Corresponding to the method embodiment, the invention also provides an embodiment of the spherical topography generating device, and fig. 11 shows a schematic structural diagram of the spherical topography generating device according to one embodiment of the invention. As shown in fig. 11, the apparatus includes:
a determining module 1102, configured to determine a grid map of a fixed grid number, and establish a mapping relationship between a center of the grid map and a center of a sphere, where the sphere is located in a world coordinate system.
Optionally, the determining module 1102 is further configured to receive the grid graph, and normalize the grid graph; initializing the direction of the grid graph after the normalization processing, so that the normal direction of the grid graph is the same as the direction of a target coordinate axis in the world coordinate system; and establishing a mapping relation between the center of the grid graph and the center of the sphere after initialization.
A calculation module 1104 is configured to calculate mapping parameters of the mesh map based on the mapping relationship.
Optionally, the calculating module 1104 further includes a target vertex determining module configured to determine a target vertex in the mesh map based on the mapping relationship, where the mesh map includes a plurality of original vertices, each original vertex corresponds to at least one mesh, and the target vertex is a vertex whose number of meshes corresponding to the original vertices is greater than a preset threshold; responding to a grid pattern changing request which is input by a user side and contains grid pattern changing parameters, and calculating the displacement of each target vertex based on the grid pattern changing parameters; and determining mapping parameters of the grid map based on the displacement of each target vertex.
Optionally, the calculating module 1104 is further configured to calculate a maximum radius of the sphere based on the sphere radius of the sphere and the maximum terrain height in response to a maximum terrain height input by a user, wherein the sphere attribute parameters include the sphere radius and the maximum radius; calculating an offset of the grid map based on a positional parameter of a camera in the world coordinate system relative to the sphere center, the sphere radius and the maximum radius; and adjusting the grid map based on the mapping parameters and the offset to obtain a grid map to be projected.
Optionally, the calculation module 1104 is further configured to calculate a rotation matrix of the grid map based on the position parameters of the camera in the world coordinate system relative to the center of sphere and the position parameters of the grid map in the world coordinate system relative to the center of sphere; and adjusting the grid map based on the mapping parameters and the rotation matrix to obtain a grid map to be projected.
Optionally, the calculation module 1104 is further configured to calculate a rotation matrix of the grid map based on the position parameters of the camera in the world coordinate system relative to the center of sphere and the position parameters of the grid map in the world coordinate system relative to the center of sphere; and adjusting the grid map based on the mapping parameters, the offset and the rotation matrix to obtain a grid map to be projected.
The adjustment module 1106 is configured to adjust the grid map based on the mapping parameter to obtain a grid map to be projected, and project the grid map to be projected onto a sphere of the sphere, so as to obtain a sphere area corresponding to each grid in the grid map to be projected on the sphere.
Optionally, the adjustment module 1106 is further configured to determine a position vector of each vertex in the grid graph to be projected relative to the center of sphere, and normalize the position vector to the center of sphere; and calculating projection points of the vertexes in the spherical surface according to the normalized position vector and the radius of the spherical surface, and determining spherical surface areas corresponding to the spherical surface of each grid in the grid graph to be projected according to the projection points.
The generating module 1108 is configured to generate spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area.
Optionally, the generating module 1108 is further configured to obtain a first intermediate result according to the three-dimensional position coordinates of the spherical terrain to be generated in each spherical area and the three-dimensional terrain function; adjusting the initial amplitude parameter and the initial frequency parameter based on a preset rule to obtain an intermediate amplitude parameter and an intermediate frequency parameter, and obtaining an intermediate three-dimensional terrain function based on the intermediate amplitude parameter and the frequency parameter; carrying out iterative processing on the three-dimensional position coordinates of the spherical terrain to be generated in each spherical area and the intermediate three-dimensional terrain function to obtain a plurality of second intermediate results; and calculating the height coordinate of the spherical terrain to be generated according to the first intermediate result and each second intermediate result, and generating the spherical terrain based on the height coordinate and each spherical area.
Optionally, the generating module 1108 is further configured to determine a sharpness scalar for each location in each spherical region, wherein the sharpness scalar is used to describe a rate of change of terrain; obtaining an absolute value function and a complementary function based on the three-dimensional topographic function, wherein the absolute value function is an absolute value function taking result of the three-dimensional topographic function, and the complementary function is a difference function between the absolute value function and 1; and adjusting the terrain sharpness of each position in each spherical area according to the sharpness scalar, the absolute value function, the supplement function and the three-dimensional terrain function.
Optionally, the generating module 1108 is further configured to determine a gradient and a gradient factor for each location in each spherical region, wherein the gradient factor is used to describe a degree of erosion of the terrain by the gradient; and calculating gradient erosion parameters of each position in each spherical surface area according to the gradient and the gradient factor, wherein the gradient erosion parameters are used for participating in the iterative processing together with the intermediate amplitude parameters and the intermediate frequency parameters.
Optionally, the generating module 1108 is further configured to determine altitude and altitude factors for each location in each spherical region, wherein the altitude factors are used to describe the altitude versus terrain erosion extent; determining the degree of concavity and a concavity factor of each position in each spherical region, wherein the concavity factor is used for describing the degree of corrosiveness of the concavity degree to the terrain; the intermediate frequency parameter is adjusted based on the altitude, the altitude factor, the degree of dishing, and the dishing factor.
Optionally, the apparatus further comprises a normal calculation module configured to determine coordinates from the locations of the spherical terrain and to obtain a height map of the spherical terrain based on the coordinates of the locations of the spherical terrain; and calculating a normal map of the spherical surface terrain based on the altitude map.
According to the spherical terrain generating device, the mapping relation between the grid patterns with the fixed grid number and the spheres is established, the number of the grids does not need to be calculated in real time, the play of the grids is adjusted, the calculated amount is reduced, and therefore the performance consumption is reduced.
The above is a schematic scheme of a spherical topography generating device of the present embodiment. It should be noted that, the technical solution of the spherical topography generating device and the technical solution of the spherical topography generating method belong to the same conception, and details of the technical solution of the spherical topography generating device which are not described in detail can be referred to the description of the technical solution of the spherical topography generating method.
Fig. 12 illustrates a block diagram of a computing device 1200 provided in accordance with an embodiment of the invention. The components of computing device 1200 include, but are not limited to, memory 1210 and processor 1220. Processor 1220 is coupled to memory 1210 by bus 1230 and database 1250 is used to store data.
The computing device 1200 also includes an access device 1240, the access device 1240 enabling the computing device 1200 to communicate via the one or more networks 1260. Examples of such networks include public switched telephone networks (PSTN, public Switched Telephone Network), local area networks (LAN, local Area Network), wide area networks (WAN, wide Area Network), personal area networks (PAN, personal Area Network), or combinations of communication networks such as the internet. The access device 1240 may include one or more of any type of network interface, wired or wireless, such as a network interface card (NIC, network interface controller), such as an IEEE802.11 wireless local area network (WLAN, wireless Local Area Network) wireless interface, a worldwide interoperability for microwave access (Wi-MAX, worldwide Interoperability for Microwave Access) interface, an ethernet interface, a universal serial bus (USB, universal Serial Bus) interface, a cellular network interface, a bluetooth interface, near field communication (NFC, near Field Communication).
In one embodiment of the invention, the above-described components of computing device 1200, as well as other components not shown in FIG. 12, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device illustrated in FIG. 12 is for exemplary purposes only and is not intended to limit the scope of the present invention. Those skilled in the art may add or replace other components as desired.
Computing device 1200 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smart phone), wearable computing device (e.g., smart watch, smart glasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or personal computer (PC, personal Computer). Computing device 1200 may also be a mobile or stationary server.
Wherein the processor 1220 is configured to execute computer-executable instructions that, when executed by the processor, perform the steps of the spherical terrain generation method described above.
The foregoing is a schematic illustration of a computing device of this embodiment. It should be noted that, the technical solution of the computing device and the technical solution of the spherical topography generating method belong to the same conception, and details of the technical solution of the computing device, which are not described in detail, can be referred to the description of the technical solution of the spherical topography generating method.
An embodiment of the present invention also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the spherical topography generation method described above.
The above is an exemplary version of a computer-readable storage medium of the present embodiment. It should be noted that, the technical solution of the storage medium and the technical solution of the spherical topography generating method belong to the same concept, and details of the technical solution of the storage medium which are not described in detail can be referred to the description of the technical solution of the spherical topography generating method.
An embodiment of the present invention also provides a computer program, wherein the computer program, when executed in a computer, causes the computer to execute the steps of the above-mentioned spherical topography generation method.
The above is an exemplary version of a computer program of the present embodiment. It should be noted that, the technical solution of the computer program and the technical solution of the spherical topography generating method belong to the same conception, and details of the technical solution of the computer program, which are not described in detail, can be referred to the description of the technical solution of the spherical topography generating method.
The foregoing describes certain embodiments of the present invention. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The computer instructions include computer program code that may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the computer readable medium can be increased or decreased appropriately according to the requirements of the patent practice, for example, in some areas, according to the patent practice, the computer readable medium does not include an electric carrier signal and a telecommunication signal.
It should be noted that, for simplicity of description, the foregoing method embodiments are all described as a series of combinations of actions, but it should be understood by those skilled in the art that the embodiments of the present invention are not limited by the order of actions described, as some steps may be performed in other order or simultaneously in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred, and that the acts and modules referred to are not necessarily all required in the embodiments of the invention.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to the related descriptions of other embodiments.
The preferred embodiments of the invention disclosed above are intended only to assist in the explanation of the invention. Alternative embodiments are not intended to be exhaustive or to limit the invention to the precise form disclosed. Obviously, many modifications and variations are possible in light of the teachings of the embodiments of the present invention. The embodiments were chosen and described in order to best explain the principles of the embodiments and the practical application, to thereby enable others skilled in the art to best understand and utilize the invention. The invention is limited only by the claims and the full scope and equivalents thereof.

Claims (15)

1. A spherical terrain generation method, comprising:
determining grid patterns with fixed grid quantity, and establishing a mapping relation between the center of the grid patterns and the sphere center of a sphere, wherein the sphere is positioned in a world coordinate system;
calculating mapping parameters of the grid map based on the mapping relation;
adjusting the grid map based on the mapping parameters to obtain a grid map to be projected, and projecting the grid map to be projected to the sphere of the sphere to obtain a sphere area corresponding to each grid in the grid map to be projected on the sphere;
and generating spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area.
2. The spherical topography generation method according to claim 1, wherein an origin of the world coordinate system is the sphere center;
correspondingly, the determining the grid map with the fixed grid number, and establishing the mapping relation between the center of the grid map and the center of the sphere, comprises the following steps:
receiving the grid graph, and carrying out normalization processing on the grid graph;
initializing the direction of the grid graph after the normalization processing, so that the normal direction of the grid graph is the same as the direction of a target coordinate axis in the world coordinate system;
And establishing a mapping relation between the center of the grid graph and the center of the sphere after initialization.
3. The spherical topography generation method according to claim 1, wherein the calculating the mapping parameters of the mesh map based on the mapping relation further comprises;
determining target vertexes in the grid graph based on the mapping relation, wherein the grid graph comprises a plurality of original vertexes, each original vertex corresponds to at least one grid, and the target vertexes are vertexes, corresponding to the original vertexes, of which the number of grids is larger than a preset threshold value;
responding to a grid pattern changing request which is input by a user side and contains grid pattern changing parameters, and calculating the displacement of each target vertex based on the grid pattern changing parameters;
and determining mapping parameters of the grid map based on the displacement of each target vertex.
4. The spherical terrain generation method according to claim 1, wherein the adjusting the mesh map based on the mapping parameter, to obtain a mesh map to be projected, includes:
responding to the maximum terrain height input by a user side, and calculating the maximum radius of the sphere based on the sphere radius of the sphere and the maximum terrain height, wherein the attribute parameters of the sphere comprise the sphere radius and the maximum radius;
Calculating an offset of the grid map based on a positional parameter of a camera in the world coordinate system relative to the sphere center, the sphere radius and the maximum radius;
and adjusting the grid map based on the mapping parameters and the offset to obtain a grid map to be projected.
5. The spherical terrain generation method according to claim 1, wherein the adjusting the mesh map based on the mapping parameter, to obtain a mesh map to be projected, includes:
calculating a rotation matrix of the grid map based on a position parameter of the camera relative to the center of sphere in the world coordinate system and a position parameter of the grid map relative to the center of sphere in the world coordinate system;
and adjusting the grid map based on the mapping parameters and the rotation matrix to obtain a grid map to be projected.
6. The spherical terrain generation method according to claim 4, wherein the adjusting the mesh map based on the mapping parameter and the offset to obtain the mesh map to be projected includes:
calculating a rotation matrix of the grid map based on a position parameter of the camera relative to the center of sphere in the world coordinate system and a position parameter of the grid map relative to the center of sphere in the world coordinate system;
And adjusting the grid map based on the mapping parameters, the offset and the rotation matrix to obtain a grid map to be projected.
7. The method for generating spherical terrain according to claim 1, wherein projecting the grid pattern to be projected onto the spherical surface of the sphere to obtain a spherical area corresponding to each grid in the grid pattern to be projected on the spherical surface, includes:
determining a position vector of each vertex in the grid graph to be projected relative to the sphere center, and normalizing the position vector to the sphere center;
and calculating projection points of the vertexes in the spherical surface according to the normalized position vector and the radius of the spherical surface, and determining spherical surface areas corresponding to the spherical surface of each grid in the grid graph to be projected according to the projection points.
8. The spherical terrain generation method according to claim 1, wherein the three-dimensional terrain function comprises an initial amplitude parameter and an initial frequency parameter;
correspondingly, the generating spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area comprises the following steps:
obtaining a first intermediate result according to the three-dimensional position coordinates of the spherical terrain to be generated in each spherical area and the three-dimensional terrain function;
Adjusting the initial amplitude parameter and the initial frequency parameter based on a preset rule to obtain an intermediate amplitude parameter and an intermediate frequency parameter, and obtaining an intermediate three-dimensional terrain function based on the intermediate amplitude parameter and the frequency parameter;
carrying out iterative processing on the three-dimensional position coordinates of the spherical terrain to be generated in each spherical area and the intermediate three-dimensional terrain function to obtain a plurality of second intermediate results;
and calculating the height coordinate of the spherical terrain to be generated according to the first intermediate result and each second intermediate result, and generating the spherical terrain based on the height coordinate and each spherical area.
9. The spherical topography generation method according to claim 8, further comprising, after the inputting the three-dimensional position coordinates of the spherical topography to be generated in each spherical region, the initial amplitude parameter, and the initial frequency parameter to a three-dimensional topography function, obtaining a first intermediate result:
determining a sharpness scalar for each location in each spherical region, wherein the sharpness scalar is used to describe a rate of change of terrain;
obtaining an absolute value function and a complementary function based on the three-dimensional topographic function, wherein the absolute value function is an absolute value function taking result of the three-dimensional topographic function, and the complementary function is a difference function between the absolute value function and 1;
And adjusting the terrain sharpness of each position in each spherical area according to the sharpness scalar, the absolute value function, the supplement function and the three-dimensional terrain function.
10. The spherical topography generation method according to claim 8, further comprising, after the inputting the three-dimensional position coordinates of the spherical topography to be generated in each spherical region, the initial amplitude parameter, and the initial frequency parameter to a three-dimensional topography function, obtaining a first intermediate result:
determining gradients and gradient factors of positions in the spherical areas, wherein the gradient factors are used for describing the erosion degree of the gradient to the terrain;
and calculating gradient erosion parameters of each position in each spherical surface area according to the gradient and the gradient factor, wherein the gradient erosion parameters are used for participating in the iterative processing together with the intermediate amplitude parameters and the intermediate frequency parameters.
11. The spherical topography generation method of claim 7, further comprising, after the adjusting the initial amplitude parameter and the initial frequency parameter based on a preset rule to obtain an intermediate amplitude parameter and an intermediate frequency parameter:
Determining the altitude and the altitude factor of each position in each spherical area, wherein the altitude factor is used for describing the erosion degree of altitude to terrain;
determining the degree of concavity and a concavity factor of each position in each spherical region, wherein the concavity factor is used for describing the degree of corrosiveness of the concavity degree to the terrain;
the intermediate frequency parameter is adjusted based on the altitude, the altitude factor, the degree of dishing, and the dishing factor.
12. The spherical topography generation method according to claim 1, further comprising, after generating spherical topography from each spherical region and a three-dimensional topography function corresponding to each spherical region:
determining coordinates of each position according to the spherical topography, and obtaining a height map of the spherical topography based on the coordinates of each position of the spherical topography; and calculating a normal map of the spherical surface terrain based on the altitude map.
13. A spherical terrain generating device, comprising:
the determining module is configured to determine a grid chart with fixed grid quantity, and establish a mapping relation between the center of the grid chart and the sphere center of a sphere, wherein the sphere is located in a world coordinate system;
A calculation module configured to calculate mapping parameters of the mesh map based on the mapping relationship;
the adjusting module is configured to adjust the grid map based on the mapping parameters to obtain a grid map to be projected, and project the grid map to be projected to the sphere of the sphere to obtain a sphere area corresponding to each grid in the grid map to be projected;
and the generation module is configured to generate spherical terrain according to each spherical area and the three-dimensional terrain function corresponding to each spherical area.
14. A computing device, comprising:
a memory and a processor;
the memory is configured to store computer executable instructions, the processor being configured to execute the computer executable instructions, which when executed by the processor, implement the steps of the spherical terrain generation method of any of claims 1-12.
15. A computer readable storage medium, characterized in that it stores computer executable instructions which, when executed by a processor, implement the steps of the spherical topography generation method of any of claims 1-12.
CN202311264161.7A 2023-09-26 2023-09-26 Spherical topography generation method and device, computing equipment and medium Pending CN117292075A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311264161.7A CN117292075A (en) 2023-09-26 2023-09-26 Spherical topography generation method and device, computing equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311264161.7A CN117292075A (en) 2023-09-26 2023-09-26 Spherical topography generation method and device, computing equipment and medium

Publications (1)

Publication Number Publication Date
CN117292075A true CN117292075A (en) 2023-12-26

Family

ID=89247611

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311264161.7A Pending CN117292075A (en) 2023-09-26 2023-09-26 Spherical topography generation method and device, computing equipment and medium

Country Status (1)

Country Link
CN (1) CN117292075A (en)

Similar Documents

Publication Publication Date Title
KR100888528B1 (en) Apparatus, method, application program and computer readable medium thereof capable of pre-storing data for generating self-shadow of a 3D object
CN112569602B (en) Method and device for constructing terrain in virtual scene
CA2314714C (en) Morphing image processing system using polygon reduction processing
CN112950769A (en) Three-dimensional human body reconstruction method, device, equipment and storage medium
CN105761314B (en) A kind of Model Simplification Method kept based on notable color attribute feature
CN113781621A (en) Three-dimensional reconstruction processing method, device, equipment and storage medium
CN116385619B (en) Object model rendering method, device, computer equipment and storage medium
CN108230430B (en) Cloud layer mask image processing method and device
CN117333637A (en) Modeling and rendering method, device and equipment for three-dimensional scene
Pfeifer A subdivision algorithm for smooth 3D terrain models
CN115546371A (en) Point cloud optimization method and system, electronic device and storage medium
JP2020532022A (en) Sphere light field rendering method in all viewing angles
CN117422811A (en) Model baking method, device, equipment and storage medium
KR20030016477A (en) Remeshing optimizing method and apparatus for polyhedral surface
CN117292075A (en) Spherical topography generation method and device, computing equipment and medium
CN115409962B (en) Method for constructing coordinate system in illusion engine, electronic device and storage medium
CN110827303B (en) Image editing method and device for virtual scene
CN114049423A (en) Automatic realistic three-dimensional model texture mapping method
Heimann et al. Joint Geometry and Attribute Upsampling of Point Clouds Using Frequency-Selective Models with Overlapped Support
CN117292038B (en) Rendering method, system, equipment and storage medium for sea surface model
CN115937457B (en) Real-time topography sketch method based on DEM image
CN114972265B (en) Texture image segmentation method, generation method, device and equipment
CN116824082B (en) Virtual terrain rendering method, device, equipment, storage medium and program product
CN114529654A (en) Model generation method and device, computer equipment and storage medium
Frommholz Image interpolation on the CPU and GPU using line run sequences

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