Disclosure of Invention
The invention mainly solves the technical problems that: in the three-dimensional model graphic processing of the electronic equipment, the scene smooth output with higher computational resource requirements cannot be realized due to hardware configuration.
Therefore, firstly, the invention provides a three-dimensional model graph rendering method which is applied to electronic equipment and comprises the following steps:
calculating a performance index: calculating performance indexes required by geometric rendering of an object to be rendered;
weight calculation ordering: if the required performance index exceeds the actual performance index of the equipment, carrying out weight calculation sequencing on the object geometry;
loading: loading the object geometric body at the front end of the sequencing into a video memory, and releasing the corresponding memory;
rendering: and rendering the objects in the video memory.
In the above three-dimensional model graphics rendering method, in an embodiment, before the step of calculating the performance index, the method further includes a working state determining process: it is determined that the operational state is in an idle frame after rendering a frame.
In an embodiment of the foregoing method for rendering a three-dimensional model graphic, before the loading step, the method further includes an unloading step: and unloading the geometric body video memory of the sequencing tail object and storing the geometric body video memory into the memory.
In the above three-dimensional model graphics rendering method, in an embodiment, the step of calculating and ordering the object geometry weights includes:
acquiring a first parameter A: obtaining dimensional values of a neutron model bounding box in the geometric object, including length, width and height, A = length2+ wide2+ high2;
Assigning a second parameter B: checking whether the object geometry is in the view frustum, if so, assigning a positive value, and if not, assigning a negative value with an absolute value equal to the positive value;
calculating a third parameter C: calculating the distance from the center point of the surrounding box of the object geometry to the video camera or the camera;
calculating an object weight value D: d = B + C3 / A;
And (3) comparison: if the signs of the weight values of the two objects are the same, performing square operation on the weight values, comparing the square values of the weight values, and arranging the smaller value in front of the two objects; if the weighted values of the two objects are different in sign, the two objects are directly compared, and the larger object is arranged in front;
sorting: according to the comparison step, pairwise comparison is carried out on the weight values of the objects, and the sequence of the objects is determined.
Meanwhile, the invention provides electronic equipment which comprises a processor, a video memory and an internal memory, wherein the processor, the video memory and the internal memory are electrically connected; when the graph is rendered, the processor calculates performance indexes required by geometric rendering of the object; if the required performance index exceeds the actual performance index of the system, carrying out weight calculation sequencing on the object geometric solid; loading the object geometry at the front end of the sequencing into the video memory, and releasing the corresponding memory; and the processor renders the objects in the video memory.
Alternatively, an electronic device, comprising: a memory for storing program code; and the processor is used for executing the program codes stored in the memory by calling to realize the graphic rendering method.
Also, the present invention provides an electronic device readable storage medium including program code that can be called and executed by a processor to implement the above-described graphics rendering method.
According to the three-dimensional model graphic rendering method, the electronic device and the readable storage medium thereof provided by the invention, in the graphic rendering method of the embodiment, the object geometric objects are subjected to weight calculation and sequencing, when the hardware performance is judged to reach the bottleneck, the model data with low weight value is preferentially stored into the memory from the video memory, the total operation amount of the CPU/GPU and the memory/video memory usage amount can be dynamically adjusted, so that the video memory space is released to provide for the model rendering with high weight value, the operation resource is distributed to the scene object concerned by the user, and the scene roaming quality is not influenced.
For the three-dimensional information model with independent characteristics, according to the graph rendering method provided by the invention, the function of model object singleization is ensured, the material state can be independently selected, hidden, assigned, inquired and the like, and the logic structure can be maintained, the original precision of the model object is ensured, and the industrial requirements are met.
The method is applied to model objects with the number more than million, reduces the requirement on the operational performance of hardware when the model objects are completely added to scene rendering, and can be adapted to more low-configuration equipment terminals for browsing; meanwhile, the quality and the precision of the model are ensured because the lightweight processing of the model quality is not needed.
Detailed Description
The present invention will be described in further detail with reference to the following detailed description and accompanying drawings. In the following description, numerous details are set forth in order to provide a better understanding of the present application. However, those skilled in the art will readily recognize that some of the features may be omitted or replaced with other elements, materials, methods in different instances. In some instances, certain operations related to the present application have not been shown or described in detail in order to avoid obscuring the core of the present application from excessive description, and it is not necessary for those skilled in the art to describe these operations in detail, so that they may be fully understood from the description in the specification and the general knowledge in the art.
Furthermore, the features, operations, or characteristics described in the specification may be combined in any suitable manner to form various embodiments. Also, the various steps or actions in the method descriptions may be transposed or transposed in order, as will be apparent to one of ordinary skill in the art. Thus, the various sequences in the specification and drawings are for the purpose of describing certain embodiments only and are not intended to imply a required sequence unless otherwise indicated where such sequence must be followed.
The numbering of the components as such, e.g., "first", "second", etc., is used herein only to distinguish the objects as described, and does not have any sequential or technical meaning. The term "connected" and "coupled" when used in this application, unless otherwise indicated, includes both direct and indirect connections (couplings).
In computer graphics processing, a view cone is usually used for limitation, and visible object objects in the view cone range are scene ranges and objects focused by a user. Referring to FIG. 1, a view frustum is a three-dimensional volume whose position is relative to the camera, and the shape of the view frustum determines how the model is projected from the camera space (camera space) onto the screen. The most common type of projection is perspective projection, with objects near the camera projected larger and objects farther from the camera projected smaller. The perspective projection uses a pyramid as a View Frustum, the camera is positioned at the top of the pyramid, the pyramid is cut off by a front plane and a rear plane to form a Frustum of a pyramid, which is called a View Frustum (View Frustum), and only a model positioned inside the Frustum of a pyramid is visible.
Referring to fig. 2, in the field of computer graphics and computational geometry, a closed space that completely encloses object combinations is defined as a bounding box, complex objects are encapsulated in a simple bounding box, and the shape of the complex geometric object is approximately replaced by the shape of the simple bounding box, so that the efficiency of geometric operations can be improved; and generally simple objects are easier to check for mutual overlap.
In the embodiment of the present invention, in the computer graphics rendering process, when a three-dimensional information model object (hereinafter referred to as an object) having an independent characteristic is rendered, different weights are given according to the relative positions of the object and a view cone:
objects within the view frustum range are given greater weight; meanwhile, objects in the cone range can be given different weights according to the distance degree, and the farther the object weight is, the lower the object weight is, the closer the object weight is, the greater the object weight is; in the current view cone range, different weights can be given according to the size of the resolution rendered by the object bounding box, and the smaller the resolution, the lower the weight of the object is, the later the model rendering sequence is adjusted.
Objects which intersect the view frustum are given smaller weight; meanwhile, different weights can be given according to the intersection degree of the two objects, the larger the proportion of the objects falling into the viewing cone during intersection is, the higher the weight is, and the lower the proportion of the objects falling into the viewing cone during intersection is, the lower the weight is.
Objects outside the cone range are given less weight; meanwhile, different weights can be given according to the degree of distance, and the farther the weight of the object is, the lower the weight of the object is, the closer the weight of the object is, the greater the weight of the object is.
Referring to fig. 3, the third object 3 is completely within the viewing cone (i.e. completely within the field of view), and the second object 2 and the fourth object 4 are both partially within the viewing cone, i.e. the two objects are partially within the field of view, or the objects are said to intersect the viewing cone. While four objects falling outside the viewing cone, a seventh object 7 behind the viewpoint, a sixth object 6 too far out of view, a first object 1 to the left outside the field of view, a fifth object 5 to the right outside the field of view, are all not inside the viewing cone. The third object 3 is an object that is rendered first, and the second object 2 and the fourth object 4 are objects that are rendered second best.
According to the principle, the object objects are subjected to weight calculation and sequencing, and when the hardware performance is judged to reach the bottleneck, a model with a high weight value is rendered preferentially; when the system has enough computing resources, the models are rendered in the order of the weights from high to low. And preferentially storing the model geometry body with low weight value from the video memory to the memory under the condition of insufficient video memory so as to release video memory space for providing the model rendering with high weight value.
Due to the fact that the operation total amount of the CPU/GPU and the use amount of the memory/video memory can be dynamically adjusted, some objects with lower weight are automatically ignored when the operation performance reaches the bottleneck period through the judgment of the rendering frame number, so that the operation resources are distributed to the scene objects concerned by the user, and the scene roaming quality is not influenced. The method has the advantages that the requirement on the operational performance of hardware is reduced when the model objects with the number more than million levels are completely added into scene rendering, and the method can be adapted to more low-configuration equipment terminals for browsing. And the quality and the precision of the model are ensured because the lightweight processing of the model quality is not needed.
When the model source data is stored in the server, the transmission of the objects with higher weight is preferentially ensured, and some objects with lower weight are ignored to strictly control the network transmission amount, so that the time cost spent on network transmission is saved, and the network transmission amount can be compressed under the condition of not sacrificing the model precision.
The first embodiment is as follows:
in this example, the scene object geometries are first ranked by weight calculation. Referring to fig. 4, the steps of the object geometry weight calculation sorting algorithm include:
acquiring a first parameter A: obtaining the size numerical values of a neutron model bounding box in the object geometry, including length, width and height; a = length of bounding box diagonal = length2+ wide2+ high2;
Assigning a second parameter B: checking whether the object geometry is within the viewing frustum, if so, assigning a value of 1, and otherwise, assigning a value of-1;
the two steps are not divided into front and back order;
calculating a third parameter C: calculating the distance from the center point of the bounding box of the object geometric body to the camera or the camera;
calculating an object weight value D: d = B + C3 / A;
And (3) comparison: if the signs of the weight values of the two objects are the same, performing square operation on the weight values, comparing the square values of the weight values, and arranging the smaller value in front of the two objects; if the weighted values of the two objects are different in sign, the two objects are directly compared, and the large object is arranged in front.
Sorting: according to the comparison step, pairwise comparison is carried out on the weight values of the objects, and the sequence of the objects is determined. In particular, conventional sorting algorithms may be applied, such as bubble sorting, quick sorting, etc.
When the performance of the current equipment meets the bottleneck of calculation performance, namely the display memory capacity is insufficient, the operation speed of a GPU and a CPU is reduced, and the like, so that the rendering frame rate (the rendering times in one second) is reduced, memory exchange is carried out, namely, objects with part of weights sorted back are moved out of the display memory into the memory; uploading data in an independent thread until all data are completely uploaded, calculating a sequencing result according to the uploading sequence, and if the sequencing objects are not uploaded, continuously uploading and adding a video memory for rendering; and then uploaded to other media such as a memory or a hard disk in sequence.
Referring to fig. 5, the process of memory exchange includes: judging whether the current hardware performance is in an idle frame, if the equipment is in the idle frame after rendering one frame, calculating performance indexes required by rendering of all the object geometric objects, namely video memory capacity, GPU and CPU operation speed, and if the required performance indexes exceed actual performance indexes of a system, performing sequencing of the object geometric objects according to the object geometric object weight calculation sequencing method, selecting the unloading quantity by combining the current hardware performance, unloading the video memory of the object geometric objects at the tail part of the sequencing, and storing the video memory of the object geometric objects in a memory; and simultaneously, selecting the loading quantity according to the current hardware performance, loading the object geometric body at the front part of the sequencing into the video memory, and releasing the corresponding memory.
And the electronic equipment continues to render the next frame of the object in the video memory.
Correspondingly, the electronic equipment of the embodiment comprises a processor, a video memory and a memory, which are electrically connected; according to the embodiment, when the graph is rendered, the processor calculates the performance index required by the geometric rendering of the object; if the required performance index exceeds the actual performance index of the system, carrying out weight calculation sequencing on the object geometric solid; loading the object geometric body at the front end of the sequencing into a video memory, and releasing the corresponding memory; and the processor renders the objects in the video memory.
Correspondingly, the above embodiments are implemented by solidifying the program code in a memory of the electronic device, where the memory is a readable storage medium, such as a hard disk or a flash disk, and is called by a processor of the electronic device to execute the above embodiments to render the object geometry.
Example two:
the difference from the first embodiment is mainly that, in this example, the model data is stored in the server, and when the user terminal renders the model data, the user terminal needs to transmit the model data to the user terminal first, because the data transmission amount is large, the transmission time cost is also increased by times, the waiting time for loading the scene data is too long, and the user experience is seriously affected in this case.
Referring to fig. 6, when the ue initializes, the ue receives parameters transmitted from the server for weight calculation; according to the object geometry weight calculation sorting method of the first embodiment, the user terminal performs weight calculation sorting of model data, calls data from the server side as needed, preferentially calls a part of model data sorted in front, and transmits the model data sorted at the tail part temporarily or after the model data is sorted. Therefore, the real-time data transmission quantity of the network is reduced, and the data transmission quantity is not compressed under the condition of sacrificing the model precision.
In another embodiment, in this example, the server actively sequences the model data to be transmitted, preferentially transmits the part of the model data sequenced at the front, and transmits the model data sequenced at the tail temporarily or after escorting.
The user terminal electronic equipment downloads the model data in the independent thread until all the data are completely downloaded, the downloading sequence calculates the sequencing result according to the weight, if the sequencing object is not downloaded, the model data are continuously downloaded and added into the video memory for rendering and presenting; and then downloaded to other media such as a memory, a hard disk, or a flash memory in sequence.
Correspondingly, the electronic equipment of the embodiment comprises a processor, a video memory and a memory, which are electrically connected; according to the embodiment, when the graph is rendered, the processor calculates the performance index required by the geometric rendering of the object; if the required performance index exceeds the actual performance index of the system, carrying out weight calculation sequencing on the object geometric solid; loading the object geometric body at the front end of the sequencing into a video memory, and releasing the corresponding memory; and the processor renders the objects in the video memory.
Correspondingly, the above embodiments are implemented by solidifying the program code in a memory of the electronic device, where the memory is a readable storage medium, such as a hard disk or a flash disk, and is called by a processor of the electronic device to execute the above embodiments to render the object geometry.
Example three:
generally, the hard disk capacity of an electronic device greatly exceeds the memory capacity, but the read-write performance of the hard disk is inferior to that of the memory. In order to solve the problem of memory capacity limitation, the limitation of system operation hardware is broken to meet a low-configuration terminal, when data of the video memory cannot be exchanged with the memory as in the first embodiment, a sorting method is calculated according to the object geometry weight of the first embodiment, as shown in fig. 7, in this embodiment, model data to be rendered are sorted first, the unloading quantity is selected in combination with the current hardware performance, the object geometry at the tail part of the sorting is unloaded from the video memory and stored in a hard disk of the electronic device; and simultaneously, selecting the loading quantity according to the current hardware performance, and loading the object geometric body at the front part of the sequencing into the video memory. The electronic equipment preferentially renders the object geometric model data in the video memory according to the sequence.
Correspondingly, the electronic equipment comprises a processor, a video memory and a hard disk, which are electrically connected; according to the embodiment, when the graph is rendered, the processor calculates the performance index required by the geometric rendering of the object; if the required performance index exceeds the actual performance index of the system, carrying out weight calculation sequencing on the object geometric solid; loading the object geometric body at the front end of the sequencing into a video memory; and the processor renders the objects in the video memory.
Correspondingly, the above embodiments are implemented by solidifying the program code in a memory of the electronic device, where the memory is a readable storage medium, such as a hard disk or a flash disk, and is called by a processor of the electronic device to execute the above embodiments to render the object geometry.
Those skilled in the art will appreciate that all or part of the functions of the various methods in the above embodiments may be implemented by hardware, or may be implemented by computer programs. The electronic device in the present invention is a device capable of executing the aforementioned computer program, and the hardware thereof may be a conventional desktop computer, a notebook computer, a tablet computer, a mobile phone terminal, an electronic game terminal, a wearable device, and the like. When all or part of the functions of the above embodiments are implemented by a computer program, the program may be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory, a random access memory, a magnetic disk, an optical disk, a hard disk, etc., and the program is called and executed by the electronic device to realize the above functions. For example, the program may be stored in a memory of the device, and when the program in the memory is executed by the processor, all or part of the functions described above may be implemented. In addition, when all or part of the functions in the above embodiments are implemented by a computer program, the program may be stored in a storage medium such as a server, another computer, a magnetic disk, an optical disk, a flash disk, or a removable hard disk, and may be downloaded or copied to a memory of a local device, or may be version-updated in a system of the local device, and when the program in the memory is executed by a processor, all or part of the functions in the above embodiments may be implemented.
The present invention has been described in terms of specific examples, which are provided to aid understanding of the invention and are not intended to be limiting. For a person skilled in the art to which the invention pertains, several simple deductions, modifications or substitutions may be made according to the idea of the invention.