Optimization Method and System for Complex Terrain Texture Mapping
By extracting the terrain characteristics of complex terrain and using texture demand prediction models, a priority list of texture loading is generated, which solves the problem of unintelligent texture loading under complex terrain, and improves rendering performance and fluency.
Patent Information
- Application Number
- CN202510306778.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-15
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-03-15
AI Technical Summary
The existing technology lacks intelligent texture loading methods in complex terrain, resulting in a degradation of rendering performance.
By extracting the topographic features of complex terrain, generating a topographic feature map, and using the texture demand prediction model to learn the association relationship between terrain features and texture requirements, obtain the viewpoint position and line of sight direction in real time, determine the visible terrain area and predicted viewpoint position, and generate a priority list for texture loading.
It realizes intelligent loading and unloading of textures under complex terrain, improves rendering performance and fluency, reduces mutations in texture loading, and improves rendering quality.
Smart Images

Figure CN119810361B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and particularly to a method and system for optimizing texture mapping of complex terrains. Background Art
[0002] In computer graphics, texture mapping is a technique for mapping image textures onto the surfaces of three-dimensional objects to increase visual details and realism, mainly including terrain data acquisition, texture selection and generation, UV coordinate mapping, multi-level texture mapping, texture blending and transition, detail texture and resolution optimization, real-time rendering and lighting calculation, etc.
[0003] Chinese Patent with publication number CN117956179A discloses a texture mapping optimization method based on texture compression and texture prefetching, including the following steps: S1: Before transmission, the server compresses and stores the texture data; S2: According to the changes in the scene in the client, prefetch the compressed texture data that may be needed in advance from the server and store it in the local cache of the client; S3: According to the requirements of the rendering object for the scene change, the client decompresses the compressed texture data that needs to be used, loads the texture data that needs to be used in real time, and binds the texture data to the corresponding rendering object; the rendering engine of the terminal device installed with the client renders the rendering object bound with the texture data and outputs the rendering image.
[0004] For complex terrain models, such as mountains, canyons, etc., a large amount of texture data is usually required. Therefore, it is unrealistic to load all the texture data completely at once because this will consume a large amount of memory and bandwidth resources, resulting in a decline in rendering performance. Existing texture mapping methods lack intelligent loading of textures under complex terrains. Summary of the Invention
[0005] This application aims to solve at least one of the technical problems in the related technologies to some extent. For this reason, an object of this application is to propose a method and system for optimizing texture mapping of complex terrains, which realizes intelligent loading and unloading of textures under complex terrains.
[0006] One aspect of this application provides a method for optimizing texture mapping of complex terrains, including:
[0007] Step S100: Extract the terrain features of the complex terrain and generate a terrain feature map;
[0008] Step S200: Collect historical terrain features, use a texture demand prediction model to learn the correlation between terrain features and texture demands, input the terrain feature map, and output texture demands;
[0009] Step S300: Obtain the viewpoint position and line-of-sight direction in real time, and determine the visible terrain area within the current frustum model;
[0010] Step S400: Determine the predicted viewpoint position within a future time according to the viewpoint position, moving speed, and acceleration.
[0011] Step S500: Generate a priority list for texture loading according to the current terrain feature map, texture requirements, and predicted viewpoint position.
[0012] The specific method for extracting the terrain features of complex terrain and generating a terrain feature map is as follows:
[0013] Step S110: Obtain the elevation data H(x, y) of the complex terrain and the resolution W×H of the elevation data; where (x, y) represents the horizontal coordinates of the terrain pixel points, the value of H(x, y) represents the terrain height at (x, y), and W and H are the width and height of the elevation data respectively.
[0014] Step S120: Determine the number of levels according to the resolution of the elevation data and define a multi-scale elevation pyramid ; where represents the scale level, is the number of levels. The elevation data of each scale level in the multi-scale elevation pyramid is obtained through downsampling. represents the elevation data of scale level l.
[0015] Step S130: Extract terrain features at each scale level l. The terrain features include macro-scale features, meso-scale features, and micro-scale features.
[0016] Step S140: Perform feature fusion on the terrain features of different scale levels to generate a terrain feature map.
[0017] The construction method of the multi-scale elevation pyramid is as follows:
[0018] Take the elevation data as the 0th layer of the multi-scale elevation pyramid, denoted as ;
[0019] For each scale level, perform Gaussian convolution on the elevation data of its upper level to obtain the smoothed elevation data, and perform downsampling on the smoothed elevation data to obtain the elevation data with half the resolution until the number of levels of the multi-scale elevation pyramid reaches L.
[0020] The specific method for collecting historical terrain features, using a texture requirement prediction model to learn the correlation between terrain features and texture requirements, and inputting the terrain feature map to output texture requirements is as follows:
[0021] Step S210: For each complex terrain type i, collect its historical terrain features and construct a terrain feature map sample and the corresponding texture requirement labels , the texture requirement labels are divided into texture type labels and texture quantity labels, and a relationship mapping library is constructed based on the terrain feature map samples and the corresponding texture requirement labels ; where, i represents the complex terrain type variable, M is the total number of complex terrain types, represents the j-th terrain feature map sample of the i-th complex terrain type, 、 respectively represent the texture type label and the texture quantity label corresponding to the j-th terrain feature map sample of the i-th complex terrain type, is the number of terrain feature map samples;
[0022] Step S220: Obtain a large-scale terrain texture dataset, design a general texture requirement prediction model based on a deep convolutional neural network model, and use the large-scale terrain texture dataset to train it. Optimize the model parameters θ through the gradient descent algorithm to obtain a pre-trained general texture requirement prediction model;
[0023] Step S230: Use the relationship mapping library to fine-tune the general texture requirement prediction model to obtain a texture requirement prediction model for complex terrain;
[0024] Step S240: Input the terrain feature map based on the texture requirement prediction model for complex terrain and output the texture requirement ;
[0025] The specific method of using the relationship mapping library to fine-tune the general texture requirement prediction model to obtain a texture requirement prediction model for complex terrain is as follows:
[0026] The general texture requirement prediction model has L layers. The convolutional layer with a feature map size greater than or equal to the bottom layer threshold is defined as the bottom layer, and the parameters of the bottom layer convolutional layer of the general texture requirement prediction model are fixed. The fully connected layer with a feature map size less than or equal to the top layer threshold is defined as the top layer, and the parameters of the top layer fully connected layer are updated;
[0027] The specific method of obtaining the viewpoint position and the line-of-sight direction in real time and determining the visible terrain area within the current frustum model is as follows:
[0028] Step S310: Obtain the viewpoint position and the line-of-sight direction , taking the viewpoint position v as the vertex, the line-of-sight direction d as the central axis, and the field of view angle α as the opening angle, construct a frustum model ; where, p represents the point within the frustum model, is the vector angle, represents the vector between the point within the frustum model and the viewpoint position and the line-of-sight direction The included angle;
[0029] Step S320: Perform interactive calculation on the frustum model and the elevation data of the complex terrain to obtain the visible terrain area in the frustum model;
[0030] Step S330: Set the distance threshold for each layer according to the distance between the viewpoint position and the visible terrain area, and divide the visible terrain area into K layers, where K is the number of layers;
[0031] The specific method for performing interactive calculation on the frustum model and the elevation data of the complex terrain to obtain the visible terrain area in the frustum model is as follows:
[0032] Step S321: Divide the terrain into blocks, each terrain block has a corresponding bounding box. For the bounding box of each terrain block, perform frustum intersection testing to obtain the terrain blocks that intersect with or are inside the frustum model. All the terrain blocks that intersect with or are inside the frustum model form a potential visible set;
[0033] Step S322: Sort the terrain blocks in the potential visible set from near to far according to the distance from the terrain block to the viewpoint of the bounding box to obtain a terrain block list;
[0034] Step S323: Create a depth buffer and initialize the depth value of the depth buffer to the maximum depth value;
[0035] Step S324: Traverse the sorted terrain block list. For each terrain block, perform depth testing to obtain the visible terrain blocks;
[0036] Step S325: Collect all the visible terrain blocks to form the final visible terrain area;
[0037] The method for setting the distance threshold for each layer is as follows:
[0038] Step S331: For each terrain block, calculate its local roughness ;
[0039] Step S332: Calculate the adjustment factor of the distance span according to the local roughness of the terrain block ;
[0040] Step S333: Calculate the adjustment factor of the distance span according to the moving speed of the viewpoint ;
[0041] Step S334: Calculate the adjustment factor of the distance span according to the real-time frame rate f of the rendering device ;
[0042] Step S335: Calculate the distance threshold for the k-th layer according to the local roughness, the moving speed of the viewpoint, and the adjustment factor of the distance span corresponding to the real-time frame rate of the rendering device ;
[0043] The specific method for dividing the visible terrain area into K layers is as follows:
[0044] Step S336: Calculate the adjustment factor of the number of layers according to the viewpoint height ; ;
[0045] Step S337: Calculate the adjustment factor of the number of layers according to the average local roughness of the terrain ; ;
[0046] Step S338: Calculate the adjustment factor of the number of layers according to the real-time frame rate of the rendering device ; ;
[0047] Step S339: Calculate the number of layers K based on the adjustment factors of the number of layers corresponding to the viewpoint height, the average local roughness of the terrain, and the real-time frame rate of the rendering device
[0048] The specific method for determining the predicted viewpoint position within a future time according to the viewpoint position, moving speed, and acceleration is as follows:
[0049] Step S410: Obtain the viewpoint position sequence , speed sequence and acceleration sequence based on the viewpoint position, moving speed, and acceleration of the viewpoint within the past time period T, and establish a viewpoint motion model
[0050] Step S420: Calculate the predicted viewpoint position at the future time t + τ based on the viewpoint motion model through numerical integration
[0051] The specific method for generating a priority list for texture loading according to the current terrain feature map, texture requirements, and predicted viewpoint position is as follows:
[0052] Step S510: Calculate the distance from the predicted viewpoint position to the visible terrain area to obtain the viewpoint distance ;
[0053] Step S520: For the horizontal coordinates of the terrain pixel points within each visible terrain area , perform a weighted sum of the terrain feature map, texture type and texture quantity, and viewpoint distance of the terrain pixel point to calculate the texture loading priority ;
[0054] Step S530: For the horizontal coordinates of each terrain pixel in each level of the visible terrain area , calculate the average value of the texture loading priorities within the neighborhood of the terrain pixel , update the texture loading priorities of all terrain pixels within the neighborhood of the terrain pixel to the average value, and generate a priority list according to the texture loading priorities of each terrain pixel
[0055] One aspect of the present application provides a complex terrain texture mapping optimization system, including:
[0056] A terrain feature extraction module, configured to extract the terrain features of the complex terrain and generate a terrain feature map
[0057] A texture demand prediction module, configured to collect historical terrain features, use a texture demand prediction model to learn the correlation between terrain features and texture demands, input the terrain feature map, and output texture demands
[0058] A visible area extraction module, configured to obtain the viewpoint position and the line-of-sight direction in real time and determine the visible terrain area within the current frustum model
[0059] A viewpoint position prediction module, configured to determine the predicted viewpoint position within a future time according to the viewpoint position, moving speed, and acceleration
[0060] A priority list generation module, configured to generate a priority list for texture loading according to the current terrain feature map, texture demands, and predicted viewpoint position
[0061] The complex terrain texture mapping optimization method and system proposed by the present application have the following advantages compared with the prior art
[0062] The present application introduces a terrain feature map. By extracting and fusing the multi-scale features of the complex terrain to form a terrain feature map, and predicting texture demands based on the terrain feature map, it takes into account the terrain characteristics of the complex terrain. The texture demands obtained based on this are used as an indicator for determining the priorities of terrain pixels, solving the problem of establishing the correlation between terrain features and texture demands under complex terrain, considering the influence of terrain features on texture loading priorities, and making the priority decision more intelligent and reasonable
[0063] The prediction result of the texture demand prediction model proposed by the present application is used as a key input for priority calculation, assigning different texture demand weights to different terrain areas, making the priority decision more accurate. At the same time, through model fine-tuning, the prediction result is targeted at specific complex terrains, further improving the effectiveness of the priority decision
[0064] This application introduces view point prediction information into the priority decision-making, making the decision-making process more forward-looking. When calculating the texture priority, texture data that may be needed in the future is pre-loaded in advance. This predictive priority decision-making method can effectively reduce the sudden loading of textures and improve the smoothness and fluency of rendering.
[0065] This application comprehensively considers terrain features, texture requirements, and view point distance factors for priority calculation, making the priority decision-making more comprehensive and reasonable. Through the method of weighted summation, the importance of different factors can be flexibly adjusted, enabling the priority calculation to adapt to different complex terrains and rendering requirements. At the same time, the priority smoothing method of neighborhood averaging processing not only improves the integrity and continuity of the decision-making but also reduces the problem of unstable rendering quality caused by priority mutations. Brief Description of the Drawings
[0066] Figure 1 is the flowchart of the complex terrain texture mapping optimization method provided by this application;
[0067] Figure 2 is the flowchart of the texture demand prediction method provided by this application;
[0068] Figure 3 is the flowchart of the texture loading priority decision-making method provided by this application;
[0069] Figure 4 is the functional module diagram of the complex terrain texture mapping optimization system provided by this application. Detailed Embodiments
[0070] To better understand this application, more detailed descriptions of various aspects of this application will be made with reference to the accompanying drawings. It should be understood that these detailed descriptions are only descriptions of the exemplary embodiments of this application and do not limit the scope of this application in any way. Throughout the specification, the same reference numerals refer to the same elements. The expression "and / or" includes any and all combinations of one or more of the associated listed items.
[0071] In the drawings, for ease of illustration, the sizes, dimensions, and shapes of the elements have been slightly adjusted. The drawings are only examples and are not drawn to an exact scale. As used herein, terms such as "substantially", "approximately", and similar terms are used as terms indicating approximation and not as terms indicating degree, and are intended to illustrate the inherent deviations in measured or calculated values that would be recognized by a person of ordinary skill in the art. Additionally, in this application, the order of description of each step process does not necessarily represent the order in which these processes occur in actual operation, unless there are clear other limitations or can be deduced from the context.
[0072] It should also be understood that expressions such as "including", "comprising", "having", "containing" and / or "comprising of" are open-ended rather than closed-ended expressions in this specification, which means that the stated features, elements and / or components exist, but do not exclude the existence of one or more other features, elements, components and / or their combinations. In addition, when an expression such as "at least one of..." appears after a list of listed features, it modifies the entire list of features rather than just an individual element in the list. In addition, when describing the embodiments of the present application, the use of "may" means "one or more embodiments of the present application". And the term "exemplary" is intended to refer to an example or illustration.
[0073] Unless otherwise defined, all terms used herein (including engineering terms and scientific and technical terms) have the same meaning as commonly understood by those of ordinary skill in the art to which this application belongs. It should also be understood that unless clearly stated in this application, words defined in common dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art, and should not be interpreted in an idealized or overly formal sense.
[0074] It should be noted that, without conflict, the embodiments in this application and the features in the embodiments can be combined with each other. The following will describe this application in detail with reference to the drawings and in combination with the embodiments.
[0075] Embodiment 1
[0076] As Figure 1 shown, the complex terrain texture mapping optimization method provided by this application includes:
[0077] Step S100: Extract the terrain features of the complex terrain and generate a terrain feature map;
[0078] The specific method for extracting the terrain features of the complex terrain and generating a terrain feature map is as follows:
[0079] Step S110: Obtain the elevation data H(x, y) of the complex terrain and the resolution W×H of the elevation data; where (x, y) represents the horizontal coordinates of the terrain pixel points, the value of H(x, y) represents the terrain height at (x, y), and W and H are the width and height of the elevation data respectively;
[0080] The width and height of the elevation data respectively correspond to the value ranges of the horizontal coordinates x and y of the terrain;
[0081] The resolution of the elevation data H(x, y) is W×H, that is, there are W sampling points in the longitude direction and H sampling points in the latitude direction. Therefore, the value range of x is [0, W - 1], and the value range of y is [0, H - 1];
[0082] Step S120: Determine the number of levels according to the resolution of the elevation data, and define a multi-scale elevation pyramid ; where represents the scale level, is the number of levels, and the elevation data of each scale level in the multi-scale elevation pyramid is obtained by downsampling;
[0083] The construction method of the multi-scale elevation pyramid is as follows:
[0084] Take the elevation data as the 0th layer of the multi-scale elevation pyramid, denoted as ;
[0085] For each scale level, perform Gaussian convolution on the elevation data of its upper level to obtain the smoothed elevation data, and perform downsampling on the smoothed elevation data to obtain the elevation data with halved resolution until the number of levels of the multi-scale elevation pyramid reaches L;
[0086] The calculation formula for the smoothed elevation data is: ; where is the Gaussian convolution kernel, wi and wj refer to the coordinate offsets relative to the center of the convolution kernel, is the convolution kernel size;
[0087] The calculation formula for the downsampling is: ;
[0088] The calculation formula for the number of levels is: ; where is the logarithmic function, is the floor function;
[0089] Step S130: Extract terrain features at each scale level l, where the terrain features include macro-scale features, meso-scale features, and micro-scale features;
[0090] The method for obtaining the macro-scale features is: by performing trend surface analysis on the elevation data of each scale level to extract the overall undulation trend of the complex terrain , and obtain the macro-scale features;
[0091] The method for obtaining the meso-scale features is: by calculating the terrain curvature on the elevation data of each scale level , and obtain the meso-scale features of the complex terrain;
[0092] The terrain elements include ridges, valleys, and slopes;
[0093] The calculation formula for the terrain curvature is: , where , is the first-order partial derivative of the elevation data , , , is the second-order partial derivative of the elevation data ;
[0094] The method for obtaining the micro-scale features is as follows: Preset the local window radius r, and calculate the local variance for the elevation data of each local window in each scale level to obtain the micro-scale features;
[0095] The calculation formula for the local variance is: , where ri and rj represent the coordinate offsets relative to the terrain pixel point, is the local window radius, is the average value of the elevation data within the local window;
[0096] The value of the local window radius is set by those skilled in the art according to experience.
[0097] Step S140: Perform feature fusion on the terrain features of different scale levels to generate a terrain feature map;
[0098] The terrain feature map is expressed as: ;
[0099] Through the above steps, by constructing a multi-scale elevation pyramid, extracting and fusing the terrain features of different scales, a multi-scale terrain feature map is obtained, providing a data basis for subsequent texture demand prediction and analysis of texture loading priorities.
[0100] Step S200: Collect historical terrain features, use a texture demand prediction model to learn the correlation between terrain features and texture demands, input the terrain feature map, and output the texture demands;
[0101] As Figure 2 shown, the specific method for collecting historical terrain features, using a texture demand prediction model to learn the correlation between terrain features and texture demands, inputting the terrain feature map, and outputting the texture demands is as follows:
[0102] Step S210: For each complex terrain type i, collect its historical terrain features, construct a terrain feature map sample and the corresponding texture demand label . The texture demand label is divided into a texture type label and a texture quantity label. Based on the terrain feature map sample and the corresponding texture demand label, construct a relationship mapping library ; where \(i\) represents the complex terrain type variable, and \(M\) is the total number of complex terrain types. represents the \(j\)-th terrain feature map sample of the \(i\)-th complex terrain type. and respectively represent the texture type label and texture quantity label corresponding to the \(j\)-th terrain feature map sample of the \(i\)-th complex terrain type. is the number of terrain feature map samples.
[0103] The texture requirement represents the requirements for the types and quantities of texture resources needed to achieve the expected rendering quality and visual effects in a specific terrain area.
[0104] Different terrain types require different types of textures to be represented, such as rocks, sand, and grass. Predicting the texture types helps to determine the main texture resources required for each terrain area.
[0105] The texture quantity reflects the amount of texture resources required for a specific terrain area. Complex terrains require more texture resources to achieve the expected rendering quality, while simple terrains require relatively fewer texture resources. The purpose of predicting the texture quantity is to estimate the texture resource requirements for each terrain area and then evaluate the priority of texture loading.
[0106] Step S220: Obtain a large-scale terrain texture dataset, design a general texture requirement prediction model based on a deep convolutional neural network model, and train it using the large-scale terrain texture dataset. Optimize the model parameters \(\theta\) through the gradient descent algorithm to obtain a pre-trained general texture requirement prediction model.
[0107] The large-scale terrain texture dataset includes terrain texture pictures and corresponding texture type and quantity labels.
[0108] The input of the general texture requirement prediction model is the terrain texture picture, and the output is the texture type and texture quantity.
[0109] The loss function of the general texture requirement prediction model is: , where and are the loss functions for the texture type and texture quantity respectively.
[0110] The loss function for the texture type is the cross-entropy loss, and the loss function for the texture quantity is the mean squared error.
[0111] Step S230: Use the relationship mapping library to fine-tune the general texture requirement prediction model to obtain a texture requirement prediction model for complex terrains.
[0112] The specific method of fine-tuning the general texture demand prediction model using the relationship mapping library to obtain a texture demand prediction model for complex terrain is as follows:
[0113] Step S231: The general texture demand prediction model has L layers. The convolutional layer with a feature map size greater than or equal to the bottom layer threshold is defined as the bottom layer, and the parameters of the bottom layer convolutional layer of the general texture demand prediction model are fixed. The fully connected layer with a feature map size less than or equal to the top layer threshold is defined as the top layer, and the parameters of the top layer fully connected layer are updated;
[0114] Exemplarily, when the bottom layer threshold is equal to 8, for a model with an input terrain feature map size of 256×256, the bottom layer includes the first 3 to 4 convolutional layers, and the top layer includes the subsequent convolutional layers and fully connected layers.
[0115] The model parameters of the texture demand prediction model are: , where represents the parameters of the fine-tuned texture demand prediction model, represents the pre-trained general texture demand prediction model, represents the parameters of the general texture demand prediction model, represents the relationship mapping library between the terrain feature map and the texture demand, represents the cross-entropy loss between the predicted texture demand and the true texture demand label, represents the regularization term, is the regularization coefficient, represents the parameter for solving the minimization expression ;
[0116] The regularization coefficient is set by those skilled in the art according to experience.
[0117] The texture demand prediction model is fine-tuned based on the general texture demand prediction model, which can utilize data more efficiently, has relatively low training efficiency and resource requirements, and can achieve good prediction results on complex terrain.
[0118] Step S240: Input the terrain feature map based on the texture demand prediction model for complex terrain and output the texture demand ;
[0119] Step S300: Real-time obtain the viewpoint position and the line-of-sight direction, and determine the visible terrain area within the current frustum model;
[0120] The specific method of real-time obtaining the viewpoint position and the line-of-sight direction and determining the visible terrain area within the current frustum model is as follows:
[0121] Step S310: Obtain the viewpoint position and the line-of-sight direction , a frustum model is constructed with the viewpoint position v as the vertex, the line-of-sight direction d as the central axis, and the field-of-view angle α as the opening angle. ; where p represents a point within the frustum model. is the included angle between vectors. represents the vector between a point within the frustum model and the viewpoint position. and the line-of-sight direction of the included angle;
[0122] The purpose of constructing the frustum model is to determine the terrain range visible from the current viewpoint, providing a basis for subsequent calculation of the visible terrain area and optimization of texture loading.
[0123] Step S320: Perform interactive calculations between the frustum model and the elevation data of the complex terrain to obtain the visible terrain area within the frustum model;
[0124] The visible terrain area refers to the terrain surface area that is covered by the frustum model and not blocked under the current viewpoint position and line-of-sight direction;
[0125] The specific method for performing interactive calculations between the frustum model and the elevation data of the complex terrain to obtain the visible terrain area within the frustum model is as follows:
[0126] Step S321: Divide the terrain into blocks, each terrain block having a corresponding bounding box. For the bounding box of each terrain block, perform a frustum intersection test to obtain the terrain blocks that intersect with or are inside the frustum model. All terrain blocks that intersect with or are inside the frustum model form a potential visible set;
[0127] The specific method for the frustum intersection test is: Transform the vertices of the bounding box from the world coordinate system to the frustum coordinate system; Check whether the transformed vertices of the bounding box satisfy the six plane equations of the frustum model; If all vertices of the bounding box are on the same side of the frustum model, the terrain block is outside the frustum model and can be culled; If the vertices of the bounding box are on different sides of the frustum model, the terrain block intersects with or is inside the frustum model;
[0128] The frustum coordinate system is a coordinate system with the viewpoint position as the origin and the line-of-sight direction as the -Z axis;
[0129] The six plane equations of the frustum model refer to: The frustum is a three-dimensional space enclosed by six planes. The six planes are the near plane, the far plane, the left plane, the right plane, the upper plane, and the lower plane. Each plane can be represented by the plane equation Ax + By + Cz + D = 0, where (A, B, C) is the normal vector of the plane and D is the directed distance from the plane to the origin of the world coordinate system;
[0130] During the above frustum culling process, the vertex coordinates of the bounding box of the terrain block are substituted into the six plane equations. By judging the positive or negative of the signed distance from the bounding box vertex to the plane, it is determined on which side of the plane the bounding box vertex is located, and further the positional relationship between the terrain block and the frustum is judged.
[0131] Step S322: Sort the terrain blocks in the potentially visible set from near to far according to the distance from the terrain block to the bounding box view point to obtain a terrain block list;
[0132] Step S323: Create a depth buffer and initialize the depth value of the depth buffer to the maximum depth value;
[0133] Preferably, the maximum depth value is 1.0; in OpenGL, the value range of the depth buffer is [0, 1], where 0 represents the nearest point and 1 represents the farthest point. Therefore, setting the maximum depth value to 1.0 can ensure that all pixels are considered to be the farthest initially and will not be occluded.
[0134] Step S324: Traverse the sorted terrain block list. For each terrain block, perform a depth test to obtain the visible terrain blocks;
[0135] The specific method of the depth test is as follows: Transform the vertices of the terrain block from the world coordinate system to the screen coordinate system; for each transformed terrain block vertex, compare its depth value with the depth value of the corresponding pixel in the depth buffer; if the depth value of the terrain block vertex is greater than the depth value of the depth buffer, the terrain block vertex is occluded and does not need to be rendered; if the depth value of the terrain block vertex is less than or equal to the depth value of the depth buffer, the vertex is visible and the depth buffer needs to be updated and the vertex needs to be rendered; if all vertices of the terrain block are occluded, the entire terrain block is occluded and can be culled; if there are visible vertices in the terrain block, the terrain block needs to be sub-divided again and the sub-region is processed recursively;
[0136] The screen coordinate system is a two-dimensional coordinate system used to represent the projection position of a three-dimensional scene on the screen;
[0137] Step S325: Collect all visible terrain blocks to form the final visible terrain area;
[0138] The calculation formula for the visible terrain area is: , represents the frustum model;
[0139] Step S330: Set the distance threshold for each layer according to the distance between the view point position and the visible terrain area, and divide the visible terrain area into K layers, where K is the number of layers;
[0140] The expression for dividing the visible terrain area into K layers is: , where and represent the distance thresholds of the k-th layer and the (k + 1)-th layer respectively, represents the visible terrain area of the k-th layer, represents the distance between the viewpoint position and the visible terrain area;
[0141] The method for setting the distance threshold of each layer is as follows:
[0142] Step S331: For each terrain block, calculate its local roughness ;
[0143] The calculation formula for the local roughness is: , where represents the area of the terrain block , represents the elevation data, represents the average elevation of the terrain block;
[0144] Step S332: Calculate the adjustment factor of the distance span according to the local roughness of the terrain block;
[0145] The calculation formula for calculating the adjustment factor of the distance span according to the local roughness of the terrain block is: , where and are the lower limit and the upper limit of the local roughness respectively;
[0146] The upper limit and the lower limit of the local roughness can be set according to the statistical characteristics of the terrain data; preferably, , , where is the average value of the local roughness of all terrain blocks;
[0147] Step S333: Calculate the adjustment factor of the distance span according to the moving speed of the viewpoint;
[0148] The calculation formula for calculating the adjustment factor of the distance span according to the moving speed of the viewpoint is: ;
[0149] Step S334: Calculate the adjustment factor of the distance span according to the real-time frame rate f of the rendering device;
[0150] The calculation formula for calculating the adjustment factor of the distance span according to the real-time frame rate f of the rendering device is: ;
[0151] Step S335: Calculate the distance threshold for the k-th layer according to the adjustment factor corresponding to the local roughness, the moving speed of the viewpoint, and the distance span of the real-time frame rate of the rendering device ;
[0152] The calculation formula for the distance threshold of the k-th layer is: ; where, is the initial distance, is the growth rate;
[0153] The initial distance and the growth rate are set by those skilled in the art according to the overall scale and level of detail of the terrain; preferably, ;
[0154] The specific method for dividing the visible terrain area into K layers is as follows:
[0155] Step S336: Calculate the adjustment factor for the number of layers according to the viewpoint height ; ;
[0156] According to the viewpoint height The calculation formula for the adjustment factor for the number of layers is: ;
[0157] The viewpoint height The calculation formula is: , where, is the elevation data of the viewpoint position, is the height of the viewpoint position;
[0158] The viewpoint height refers to the actual height of the viewpoint relative to the terrain surface;
[0159] Step S337: Calculate the adjustment factor for the number of layers according to the average local roughness of the terrain; ;
[0160] According to the average local roughness of the terrain, the calculation formula for the adjustment factor for the number of layers is: ;
[0161] Step S338: Calculate the adjustment factor for the number of layers according to the real-time frame rate of the rendering device; ;
[0162] According to the real-time frame rate of the rendering device, the calculation formula for the adjustment factor for the number of layers is: ;
[0163] Step S339: Calculate the number of layers K based on the viewpoint height, the average local roughness of the terrain, and the adjustment factor for the number of layers corresponding to the real-time frame rate of the rendering device;
[0164] The calculation formula for the number of layers is: , where is the base number of layers, is the floor function;
[0165] The base number of layers can be set according to the overall scale and level of detail of the terrain;
[0166] Preferably, ;
[0167] Step S400: Determine the predicted viewpoint position within the future time according to the viewpoint position, movement speed, and acceleration;
[0168] The specific method for determining the predicted viewpoint position within the future time according to the viewpoint position, movement speed, and acceleration is:
[0169] Step S410: Obtain the viewpoint position sequence , speed sequence and acceleration sequence based on the viewpoint position, movement speed, and acceleration of the viewpoint within the past time period T, and establish a viewpoint motion model;
[0170] The expression of the viewpoint motion model is: ; where respectively represent the viewpoint position, movement speed, and acceleration at time t, is the time step;
[0171] Step S420: Calculate the predicted viewpoint position at the future time t + τ based on the viewpoint motion model by means of numerical integration;
[0172] The calculation formula of the numerical integration method is: ; where respectively represent the predicted viewpoint position and movement speed at the future time ;
[0173] Step S500: Generate a priority list for texture loading according to the current terrain feature map, texture requirements, and predicted viewpoint position;
[0174] As Figure 3 shown, the specific method for generating a priority list for texture loading according to the current terrain feature map, texture requirements, and predicted viewpoint position is:
[0175] Step S510: Calculate the distance from the predicted viewpoint position to the visible terrain area to obtain the viewpoint distance ;
[0176] Step S520: For each terrain pixel point's horizontal coordinate within each visible terrain area , perform a weighted sum of the terrain feature map, texture type and texture quantity, and viewpoint distance of this terrain pixel point to calculate the texture loading priority ;
[0177] The calculation formula for the texture loading priority is: ; where is the terrain feature map, and are the predicted texture type and texture quantity respectively, is the viewpoint distance, is the weight coefficient;
[0178] The value of the weight coefficient is set by those skilled in the art according to experience.
[0179] Step S530: For each terrain pixel point's horizontal coordinate within each level of the visible terrain area , calculate the average value
[0180] of the texture loading priorities within the neighborhood of this terrain pixel point, update the texture loading priorities of all terrain pixel points within the neighborhood of this terrain pixel point to the average value, and generate a priority list according to the texture loading priority of each terrain pixel point; The calculation formula for the average value of the texture loading priorities within the neighborhood of the terrain pixel point is: where is the neighborhood of the terrain pixel point, is the neighborhood size,
[0181] Preferably, a 3×3 square window is selected for the neighborhood of the terrain pixel point;
[0182] Furthermore, for the junction area between two levels of the visible terrain area, a priority mixing method is used for smooth transition, and the texture loading priority of the junction area is ; where b is the transition factor, which is used to control the mixing ratio.
[0183] b is adjusted by those skilled in the art according to the relative position of the terrain pixel point's horizontal coordinate within the junction area to achieve a smoother transition effect.
[0184] The above process makes the texture loading priority of adjacent regions smoother, reduces mutations, and improves visual continuity.
[0185] Embodiment 2
[0186] As Figure 4 shown, the complex terrain texture mapping optimization system provided by this application includes:
[0187] A terrain feature extraction module, which is used to extract the terrain features of complex terrain and generate a terrain feature map;
[0188] A texture demand prediction module, which is used to collect historical terrain features, use a texture demand prediction model to learn the correlation between terrain features and texture demands, input the terrain feature map, and output the texture demands;
[0189] A visible area extraction module, which is used to obtain the viewpoint position and line-of-sight direction in real time and determine the visible terrain area within the current frustum model;
[0190] A viewpoint position prediction module, which is used to determine the predicted viewpoint position within a future time according to the viewpoint position, moving speed, and acceleration;
[0191] A priority list generation module, which is used to generate a priority list for texture loading according to the current terrain feature map, texture demands, and predicted viewpoint position.
[0192] In addition, the parts of the above technical solutions provided in the embodiments of this application that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.
[0193] As described in the specific embodiments above, the purpose, technical solutions, and beneficial effects of the present invention are further described in detail. It should be understood that the above are only specific embodiments of the present invention and are not used to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. Complex terrain texture mapping optimization method, characterized in that: include: Extract terrain features of complex terrain and generate terrain feature maps; Collect historical terrain features, use the texture demand prediction model to learn the correlation between terrain features and texture demand, input terrain feature map, and output texture demand; Obtain the viewpoint position and sight direction in real time to determine the visible terrain area within the current frustum model; Determine the predicted viewpoint position in the future time according to the viewpoint position, moving speed and acceleration; Generate a priority list of textures to be loaded based on the current terrain feature map, texture requirements, and predicted viewpoint position; The specific method of extracting the terrain features of complex terrain and generating a terrain feature map is as follows: Obtain the elevation data H(x,y) of the complex terrain and the resolution W×H of the elevation data; where (x,y) represents the horizontal coordinates of the terrain pixel point, the value of H(x,y) represents the terrain height at (x,y), and W and H are the width and height of the elevation data respectively; Determine the number of levels based on the resolution of the elevation data and define a multi-scale elevation pyramid ;in, Indicates the scale level, is the number of levels, and the elevation data of each scale level in the multi-scale elevation pyramid is obtained by downsampling. Represents elevation data at scale level l; Extracting terrain features at each scale level l, wherein the terrain features include macro-scale features, meso-scale features, and micro-scale features; The terrain features at different scale levels are integrated to generate a terrain feature map; The specific method of collecting historical terrain features, using the texture demand prediction model to learn the correlation between terrain features and texture requirements, inputting a terrain feature map, and outputting texture requirements is as follows: For each complex terrain type i, collect its historical terrain characteristics and construct a terrain feature map sample and the corresponding texture requirement tag The texture requirement labels are divided into texture type labels and texture quantity labels. A relationship mapping library is constructed based on terrain feature map samples and corresponding texture requirement labels. ; where i represents the complex terrain type variable, M is the total number of complex terrain types, represents the jth terrain feature map sample of the i-th complex terrain type, , They represent the texture type label and texture quantity label corresponding to the jth terrain feature map sample of the i-th complex terrain type, is the number of samples of terrain feature map; Obtain a large-scale terrain texture dataset, design a general texture demand prediction model based on a deep convolutional neural network model, and train it using the large-scale terrain texture dataset. Optimize the model parameter θ through the gradient descent algorithm to obtain a pre-trained general texture demand prediction model. The general texture demand prediction model is fine-tuned using the relational mapping library to obtain a texture demand prediction model for complex terrains; Based on the texture demand prediction model for complex terrain, the terrain feature map is input and the texture demand is output. .
2. The complex terrain texture mapping optimization method according to claim 1, characterized in that: The specific method of obtaining the viewpoint position and the line of sight direction in real time and determining the visible terrain area in the current view cone model is: Get the viewpoint position and sight direction , with the viewpoint position v as the vertex, the line of sight direction d as the central axis, and the field of view angle α as the opening angle, the cone model is constructed ; Where p represents a point in the viewing cone model, is the vector angle, Represents the vector between the point in the frustum model and the viewpoint position With sight direction The angle of Interactively calculate the cone model and the elevation data of complex terrain to obtain the visible terrain area in the cone model; According to the distance between the viewpoint position and the visible terrain area, the distance threshold of each layer is set, and the visible terrain area is divided into K layers, where K is the number of layers.
3. The complex terrain texture mapping optimization method according to claim 2, characterized in that: The method for setting the distance threshold of each layer is: For each terrain patch, calculate its local roughness ; Calculates an adjustment factor for the distance span based on the local roughness of the terrain patch ; According to the speed of viewpoint movement , calculate the adjustment factor for the distance span ; Calculate the adjustment factor of the distance span based on the real-time frame rate f of the rendering device ; Calculate the distance threshold of the kth layer based on the adjustment factor of the distance span corresponding to the local roughness, the moving speed of the viewpoint, and the real-time frame rate of the rendering device .
4. The complex terrain texture mapping optimization method according to claim 3, characterized in that: The specific method of dividing the visible terrain area into K layers is: According to the viewpoint height , calculate the adjustment factor of the number of layers ; According to the average local roughness of the terrain , calculate the adjustment factor of the number of layers ; According to the real-time frame rate of the rendering device , calculate the adjustment factor of the number of layers ; The number of layers K is calculated based on the viewpoint height, the average local roughness of the terrain, and the adjustment factor of the number of layers corresponding to the real-time frame rate of the rendering device.
5. The complex terrain texture mapping optimization method according to claim 4, characterized in that: The specific method for determining the predicted viewpoint position in the future time according to the viewpoint position, moving speed and acceleration is: According to the viewpoint position, moving speed and acceleration of the viewpoint in the past time period T, the viewpoint position sequence is obtained , speed sequence and acceleration sequence , establish a viewpoint motion model; Based on the viewpoint motion model, the predicted viewpoint position at the future time t+τ is calculated by numerical integration method.
6. The complex terrain texture mapping optimization method according to claim 5, characterized in that: The specific method of generating a priority list of texture loading according to the current terrain feature map, texture requirements and predicted viewpoint position is: Calculate the distance from the predicted viewpoint position to the visible terrain area to get the viewpoint distance ; For each visible terrain area The horizontal coordinates of the terrain pixels within , perform weighted summation of the terrain feature map, texture type and texture quantity, and viewpoint distance of the terrain pixel point to calculate the texture loading priority ; For each terrain pixel in each level of the visible terrain area, the horizontal coordinate , calculate the average value of the texture loading priority in the neighborhood of the terrain pixel point , update the texture loading priority of all terrain pixels in the neighborhood of the terrain pixel to the average value, and generate a priority list based on the texture loading priority of each terrain pixel.
7. A complex terrain texture mapping optimization system, which is used to implement the complex terrain texture mapping optimization method according to any one of claims 1 to 6, characterized in that: include: A terrain feature extraction module is used to extract the terrain features of complex terrain and generate a terrain feature map; The texture demand prediction module is used to collect historical terrain features, use the texture demand prediction model to learn the correlation between terrain features and texture requirements, input terrain feature maps, and output texture requirements; The visible area extraction module is used to obtain the viewpoint position and line of sight direction in real time and determine the visible terrain area within the current frustum model; A viewpoint position prediction module, used to determine the predicted viewpoint position in the future time according to the viewpoint position, moving speed and acceleration; The priority list generation module is used to generate a priority list for texture loading based on the current terrain feature map, texture requirements and predicted viewpoint position.
Citation Information
Patent Citations
Texture mapping optimization method based on texture compression and texture prefetching
CN117956179A
LOD generation method of three-dimensional model with texture
CN118552680A
Displaying graphical textures
CN1961339A