Three-dimensional model rendering optimization method and device, equipment, medium and product

By preprocessing and building spatial tree of component geometry data of the three-dimensional model, combined with pixel culling technology, the problem of not optimizing rendering from the perspective of screen pixel occupation in the existing technology is solved, and the effect of significantly improving rendering efficiency is achieved.

CN119941954APending Publication Date: 2025-05-06TRANSLATION INFORMATION TECH (SHANGHAI) CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510057353.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

The existing three-dimensional model rendering optimization solution does not start from the perspective of screen pixel occupancy, resulting in insufficient improvement of rendering efficiency.

Method used

By preprocessing the component geometry data of the three-dimensional model to be rendered, geometric units are generated and spatial trees are constructed, combining blocks to be rendered, and geometric tuples are traversed in order from large to small according to the primitive size, the screen projection size value is calculated, and rendering is terminated if it is less than the preset threshold.

Benefits of technology

Effectively identify and block three-dimensional model contents with small screen pixels, significantly improve rendering efficiency, and is suitable for rendering of large scene models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119941954A_ABST
    Figure CN119941954A_ABST
Patent Text Reader

Abstract

The invention discloses a three-dimensional model rendering optimization method and device, equipment, a medium and a product, and relates to the technical field of model rendering. The method comprises the following steps: firstly, performing data processing on component geometric data under a three-dimensional model to be rendered, and sequentially generating all geometric units, a space tree of which only leaf nodes are allocated with the geometric units, and a combination block to be rendered which corresponds to each leaf node and comprises a vertex data set and a geometric primitive set; when the model is rendered, all geometric primitive groups in the geometric primitive group set of the combined block to be rendered are traversed in sequence from large to small according to the primitive sizes; according to the nearest point of the camera and the maximum size of the geometric primitive group which is being traversed at present, a view matrix and a projection matrix of a virtual camera are applied; and calculating to obtain a screen projection size value corresponding to the geometric primitive group, and finally determining whether to render the geometric primitive group according to a comparison result of the size value and a preset threshold value, so that the rendering efficiency can be greatly improved after the three-dimensional model is measured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of model rendering, and specifically relates to a three-dimensional model rendering optimization method, device, equipment, medium and product. Background Art

[0002] The uses of BIM (Building Information Modeling) graphics engines mainly include processing parametric design software data, creating and displaying building information models, and improving the usability and display quality of digital products. As the underlying foundation of intelligent construction and digital twins, BIM graphics engine technology plays a key leading role in the development of engineering digitalization. It is a standard dimension for carrying data and a basic object for data interaction, product design, operation and maintenance. With the continuous development of modeling technology and the improvement of lean management requirements, the volume of three-dimensional models is increasing and the sophistication is gradually increasing. High-performance graphics engines play an important role in promoting engineering digitalization.

[0003] At present, general architectural 3D models are naturally large in size and have many components. If various optimization strategies are not adopted to improve the rendering frame rate, it is impossible to ensure that the 3D model can be viewed / operated within the frame rate range. The existing commonly used model rendering optimization methods mainly include the following two methods:

[0004] (1) Culling technology: specifically including frustum culling, backface culling and occlusion culling. Frustum culling is to cull unnecessary object models by judging the distance between the object and the virtual camera or whether it is within the frustum of the virtual camera, thereby improving rendering efficiency; backface culling is to cull invisible parts (because the invisible parts do not contribute to the final image); occlusion culling is to determine which object models will be occluded by using depth testing, thereby reducing the number of object models that need to be rendered;

[0005] (2) Instancing technology: that is, through instancing technology, the number of draw calls can be reduced and rendering performance can be improved (instancing allows the same material and transformation to be used for multiple objects on the graphics processor for batch rendering, thereby reducing the resource overhead of the central processing unit and the graphics processor). Specifically, it includes reducing the number of draw calls, reducing the number of vertices and using appropriate rendering technology. Among them, reducing the number of draw calls is to reduce the number of drawing commands that need to be executed by the graphics processor by merging drawing operations and / or using batch drawing, thereby improving rendering efficiency; reducing the number of vertices is to reduce the number of vertices that need to be drawn by reducing the subdivision of the model and / or using LOD (Level of Detail) technology, thereby reducing the rendering burden of the graphics processor; using appropriate rendering technology is to select the appropriate rendering technology according to the specific scene, such as using deferred shaders and / or forward rendering to improve rendering performance.

[0006] The above model rendering optimization methods are essentially to reduce the content and number of drawings as much as possible, but they are just to optimize the various rendering processes from different angles and directions to improve the overall rendering efficiency. However, there is another principle that cannot be ignored, that is, no matter how large the scene is, no matter how much content needs to be rendered in each frame, any object model that wants to be displayed on the screen will be projected as specific and colored pixels so that it can be displayed through the display (this stage can also be called rasterization). So there is such an idea: Can the entire rendering process be optimized from the perspective of screen pixel occupation? That is, if a face is very far away from the virtual camera, and only a few pixels are finally projected on the screen, if it can be basically ignored from the perspective of naked eye visibility, it is actually possible not to render the face; for example, for a building, if all professional components need to be rendered, when people look at it from a relatively long distance from the outside, the various equipment, pipelines and furniture inside, etc., will eventually occupy very small pixels projected on the display screen, and at this time it is completely possible to consider not drawing and rendering its content. Therefore, how to identify the three-dimensional model content that occupies very small screen pixels and block its rendering, so as to greatly improve the rendering efficiency after the volume of the three-dimensional model increases, is a topic that technical personnel in this field urgently need to study. Summary of the invention

[0007] The purpose of the present invention is to provide a three-dimensional model rendering optimization method, device, computer equipment, computer-readable storage medium and computer program product to solve the problem that the existing three-dimensional model rendering optimization scheme has not yet optimized the entire rendering process from the perspective of screen pixel occupancy to achieve improved rendering efficiency.

[0008] In order to achieve the above object, the present invention adopts the following technical solutions:

[0009] In a first aspect, a 3D model rendering optimization method is provided, comprising:

[0010] Preprocessing the component geometric data under the three-dimensional model to be rendered to generate all geometric units, wherein the geometric units include vertex data;

[0011] Constructing a spatial tree in which only leaf nodes are assigned with the geometric units according to all the geometric units;

[0012] For each leaf node on the spatial tree, generating a corresponding combination block to be rendered according to all the geometric units assigned to the corresponding node, wherein the combination block to be rendered includes a vertex data set;

[0013] Generate a geometric primitive group set according to the vertex data set of the combined block to be rendered, and add the geometric primitive group set to the combined block to be rendered, wherein the geometric primitive group set includes at least one geometric primitive group arranged in descending order according to primitive sizes;

[0014] When rendering the three-dimensional model to be rendered, each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered is traversed in order from large to small according to the primitive size: according to the camera's nearest point and the maximum size of the geometric primitive group currently being traversed, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the geometric primitive group currently being traversed, and determine whether the screen projection size value is greater than or equal to zero and less than a first preset threshold value. If so, terminate the rendering of the geometric primitive group currently being traversed and all geometric primitive groups that are not currently traversed, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combined block to be rendered and closest to the virtual camera.

[0015] Based on the above invention content, a new scheme for optimizing three-dimensional model rendering based on pixel culling rendering is provided, that is, firstly, data processing is performed on the component geometric data under the three-dimensional model to be rendered, and all geometric units, a spatial tree with only leaf nodes assigned with geometric units, and a combination block to be rendered corresponding to each leaf node and containing a vertex data set and a geometric primitive group set are generated in sequence, and then when rendering the model, each geometric primitive group in the geometric primitive group set of the combination block to be rendered is traversed in order from large to small according to the primitive size: according to the camera's nearest point and the maximum size of the geometric primitive group currently being traversed, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the geometric primitive group, and finally, according to the comparison result between the size value and the preset threshold, it is determined whether to render the geometric primitive group. In this way, from the perspective of screen pixel occupancy, the three-dimensional model content with very small screen pixel occupancy can be identified and its rendering can be shielded, and then after the volume of the three-dimensional model is increased, the rendering efficiency can be greatly improved, which is convenient for practical application and promotion.

[0016] In a possible design, the component geometry data under the 3D model to be rendered is preprocessed according to the basic rendering rules to generate all the geometry units, including:

[0017] Traversing the components under the three-dimensional model to be rendered, and obtaining geometric data of each component, wherein the geometric data contains vertex information;

[0018] For each component, the corresponding geometric data is preprocessed based on the basic rendering rules and the quantization compression algorithm to obtain at least one corresponding geometric unit, wherein the geometric unit includes vertex data, and the basic rendering rules include the following rules (A1) to (A3):

[0019] (A1) Each geometric unit corresponds to only one material, where the material refers to a color or texture map defined under the three-dimensional model to be rendered;

[0020] (A2) the number of vertices of each geometric unit is less than or equal to a second preset threshold;

[0021] (A3) Each geometric unit contains only one type of rendering primitive, which is a triangle primitive type, a line primitive type or a point primitive type.

[0022] In a possible design, constructing a space tree in which only leaf nodes are assigned with the geometric units according to all the geometric units includes the following steps S21 to S25:

[0023] S21. Create a root node of the space tree, and assign all the geometric units to the root node, and then use the root node as a tree node to execute step S22;

[0024] S22. According to all the geometric units assigned to the tree node, determine whether the fork stop condition is satisfied. If so, use the tree node as a leaf node of the spatial tree and stop forking new child nodes. Otherwise, execute step S23, wherein the fork stop condition includes the following conditions (B1) to (B3):

[0025] (B1) the total number of all geometric units assigned to the tree node is less than or equal to a third preset threshold;

[0026] (B2) the total number of vertices of all geometric units assigned to the tree node is less than or equal to a fourth preset threshold;

[0027] (B3) There is only one geometric unit assigned to the tree node;

[0028] S23. Obtain the length, width and height parameters of the tree node bounding box, and then execute step S24, wherein the tree node bounding box refers to an AABB bounding box used to enclose all geometric units assigned to the tree node;

[0029] S24. Create the first child node and the second child node of the tree node, and for each geometric unit assigned to the tree node, if the length, width and height parameters of the corresponding unit bounding box meet the following conditions: UBL x >λ×BL x 、UBL y >λ×BL y and / or UBL z >λ×BL z , the corresponding unit is transferred and assigned to the first child node, otherwise the corresponding unit is transferred and assigned to the second child node, and then step S25 is executed, wherein the unit bounding box refers to the AABB bounding box used to enclose the geometric unit, UBL x Indicates the length parameter in the length, width and height parameters of the unit bounding box, BL x Represents the length parameter in the length, width and height parameters of the tree node bounding box, UBL y Indicates the width parameter in the length, width and height parameters of the unit bounding box, BL y Represents the width parameter in the length, width and height parameters of the tree node bounding box, UBL z Indicates the height parameter in the length, width and height parameters of the unit bounding box, BL z represents the height parameter in the length, width and height parameters of the tree node bounding box, and λ represents a pure decimal between 0.25 and 0.4;

[0030] S25. Take the first child node and the second child node as a new tree node respectively, and return to execute step S22.

[0031] In a possible design, for each leaf node on the spatial tree, a corresponding combined block to be rendered is generated according to all the geometric units assigned to the corresponding node, including:

[0032] For a leaf node on the spatial tree, performing a rendering error check on basic rendering data in all the geometric units allocated to the corresponding node;

[0033] After checking that there are no errors, the vertex data quantization compression parameters are calculated according to the upper and lower limits of the range of the leaf node bounding box and the upper and lower limits of the precision range of the vertex data compression target type: vertex compression offset value, vertex compression scaling value, vertex decompression offset value and vertex decompression release value, wherein the leaf node bounding box refers to the AABB bounding box used to enclose all the geometric units assigned to the certain leaf node, and the vertex compression offset value PackOffset, the vertex compression scaling value PackScale, the vertex decompression offset value UnpackOffset and the vertex decompression release value UnpackScale are calculated as follows:

[0034]

[0035] In the formula, BOX max Indicates the upper limit of the bounding box of the leaf node, BOX min Indicates the lower limit of the bounding box of the leaf node, Compress max Indicates the upper limit of the precision range of the vertex data compression target type. min Indicates the lower limit of the precision range of the vertex data compression target type;

[0036] For each vertex data in all the geometric units assigned to the leaf node, the vertex compression offset value PackOffset and the vertex compression scaling value PackScale are applied to calculate the corresponding compressed vertex data Position according to the following formula: compress :

[0037] Position compress =(Position origin +PackOffset)×PackScale

[0038] Where, Position origin Indicates vertex data before compression;

[0039] According to the array order of the vertex data in all the geometric units allocated to the leaf nodes, the compressed vertex data corresponding to the vertex data are sequentially added to the vertex data set;

[0040] Generate a certain leaf node and a to-be-rendered combined block including the vertex data set and the decompressed offset value UnpackOffset and the decompressed scale value UnpackScale, wherein the decompressed offset value UnpackOffset and the decompressed scale value UnpackScale are used to decompress and restore the respective vertex data according to the following formula during rendering:

[0041] Position o ' rigin =Position compress ×UnpackScale+UnpackOffset

[0042] Where, Position o ' rigin Represents the restored vertex data.

[0043] In a possible design, generating a set of geometric primitives according to the vertex data set of the to-be-rendered combined block includes the following steps S41 to S48:

[0044] S41. Generate all geometric primitives according to the vertex data set in the combined block to be rendered, and then execute step S42. Wherein, the geometric primitives correspond one-to-one to the vertex data groups in the vertex data set;

[0045] S42. Arrange all the geometric primitives in descending order according to the size of the primitives to obtain a geometric primitive sequence, and then execute step S43;

[0046] S43. Traverse the sequence number of geometric primitives Initialize to 1, and also traverse the size interval boundary sequence number Initialize to Then, step S44 is performed, wherein: It indicates the total number of boundary values ​​in the sequence of boundary values ​​of the size interval arranged in ascending order of numerical value;

[0047] S44. Determine the first Is the size of the geometric primitive smaller than the first value in the sequence of boundary values ​​of the size interval? If yes, execute step S45, otherwise execute step S46;

[0048] S45.Judgment Is it equal to 1? If so, execute step S48. Otherwise, Decrement by 1, and then return to execute step S44;

[0049] S46. Determine whether the A geometric tuple is created for each size interval boundary value. If so, the first The geometric primitive is added to the geometric primitive group, and then step S47 is executed, otherwise for the first Create a new geometric primitive group with the size interval boundary value and set the The geometric primitives are added to the new geometric primitive group, and then step S47 is executed;

[0050] S47. Judgment Is it equal to If yes, then execute step S48, otherwise Increment by 1, and then return to step S44, where: The total number of primitives representing the geometric primitive sequence;

[0051] S48. Arrange all geometric primitive groups in order from earliest to latest according to the creation time to obtain a geometric primitive group set, wherein the geometric primitive group set contains at least one geometric primitive group arranged in order from largest to smallest according to the primitive size.

[0052] In a possible design, each geometric primitive group in the set of geometric primitive groups of the to-be-rendered combined block is traversed in order from large to small according to the primitive size, including:

[0053] According to the camera's nearest point and the maximum size of the first geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the first geometric primitive group, and determine whether the screen projection size value is less than zero. If so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size; otherwise, continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to the point determined according to the vertex data set of the combined block to be rendered and closest to the virtual camera;

[0054] And / or, according to the camera's nearest point and the maximum size of the first geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, the view matrix and the projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the first geometric primitive group, and determine whether the screen projection size value is greater than a first preset threshold value, if so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, otherwise continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to a point determined according to the vertex data set of the combined block to be rendered and closest to the virtual camera;

[0055] And / or, based on the camera's nearest point and the maximum size of the last geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the last geometric primitive group, and determine whether the screen projection size value is less than a first preset threshold value. If so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size; otherwise, continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combined block to be rendered and closest to the virtual camera.

[0056] In a second aspect, a three-dimensional model rendering optimization device is provided, including a geometric unit generation module, a space tree construction module, a combination block generation module, a geometric primitive grouping module and a primitive group rendering module which are sequentially connected in communication;

[0057] The geometric unit generation module is used to pre-process the component geometric data under the three-dimensional model to be rendered to generate all geometric units, wherein the geometric units include vertex data;

[0058] The spatial tree construction module is used to construct a spatial tree in which only leaf nodes are assigned with the geometric units according to all the geometric units;

[0059] The combined block generation module is used to generate a corresponding combined block to be rendered for each leaf node on the spatial tree according to all the geometric units assigned to the corresponding node, wherein the combined block to be rendered includes a vertex data set;

[0060] The geometric primitive grouping module is used to generate a geometric primitive group set according to the vertex data set of the combined block to be rendered, and add the geometric primitive group set to the combined block to be rendered, wherein the geometric primitive group set includes at least one geometric primitive group arranged in descending order according to primitive size;

[0061] The primitive group rendering module is used to traverse each geometric primitive group in the geometric primitive group set of the combination block to be rendered in descending order according to the primitive size when rendering the three-dimensional model to be rendered: according to the camera's nearest point and the maximum size of the geometric primitive group currently being traversed, apply the view matrix and projection matrix of the virtual camera to calculate the screen projection size value corresponding to the geometric primitive group currently being traversed, and determine whether the screen projection size value is greater than or equal to zero and whether it is less than a first preset threshold value. If so, terminate the rendering of the geometric primitive group currently being traversed and all geometric primitive groups that are not currently traversed, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combination block to be rendered and closest to the virtual camera.

[0062] In a third aspect, the present invention provides a computer device comprising a memory, a processor and a transceiver which are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive messages, and the processor is used to read the computer program to execute the three-dimensional model rendering optimization method as described in the first aspect or any possible design of the first aspect.

[0063] In a fourth aspect, the present invention provides a computer-readable storage medium having instructions stored thereon, which, when executed on a computer, executes the three-dimensional model rendering optimization method as described in the first aspect or any possible design of the first aspect.

[0064] In a fifth aspect, the present invention provides a computer program product, comprising a computer program or instructions, which, when executed by a computer, implements the three-dimensional model rendering optimization method as described in the first aspect or any possible design of the first aspect.

[0065] Beneficial effects of the above scheme:

[0066] (1) The present invention creatively provides a new solution for optimizing 3D model rendering based on pixel culling rendering, that is, firstly, data processing is performed on the component geometric data under the 3D model to be rendered, and all geometric units, a spatial tree with only leaf nodes assigned with geometric units, and a to-be-rendered combination block corresponding to each leaf node and containing a vertex data set and a geometric primitive group set are generated in sequence. Then, when rendering the model, each geometric primitive group in the geometric primitive group set of the to-be-rendered combination block is traversed in descending order according to the primitive size: according to the camera's nearest point and the maximum size of the geometric primitive group currently being traversed, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the geometric primitive group. Finally, according to the comparison result between the size value and a preset threshold, it is determined whether to render the geometric primitive group. In this way, from the perspective of screen pixel occupancy, the 3D model content with a very small screen pixel occupancy can be identified and its rendering can be shielded. Then, after the 3D model volume is increased, the rendering efficiency can be greatly improved, which is convenient for practical application and promotion.

[0067] (2) Through data compression, that is, compressing several types of data used for rendering, the amount of drawing cache can be greatly reduced, that is, the graphics processor memory usage is reduced;

[0068] (3) By dividing the model into blocks, that is, no longer drawing the model in components, the number of drawing commands is greatly reduced;

[0069] (4) By grouping primitives and culling pixels, the amount of drawn content can be dynamically adjusted according to the camera distance, which greatly reduces the actual cache usage, that is, the amount of drawn content is reduced;

[0070] (5) Compared with conventional rendering processes, the rendering speed is greatly improved, which is very suitable for rendering and functional applications of large scene models under BIM graphics engines;

[0071] (6) It can also be seamlessly combined or combined with any optimization strategy to achieve higher rendering efficiency. That is, whether it is conventional camera culling, backface culling or occlusion culling, or more advanced LOD or dynamic loading and unloading technology, they can be combined with each other to improve rendering efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0073] Figure 1A flowchart of a three-dimensional model rendering optimization method provided in an embodiment of the present application.

[0074] Figure 2 This is an example diagram of the enclosing relationship between the AABB bounding box and the geometric unit provided in an embodiment of the present application.

[0075] Figure 3 An example diagram of generating a to-be-rendered combined block containing only one object based on multiple components under a leaf node provided in an embodiment of the present application.

[0076] Figure 4 An example diagram of geometric primitive grouping provided in an embodiment of the present application.

[0077] Figure 5 An example diagram illustrating the pixel culling rendering principle provided in an embodiment of the present application.

[0078] Figure 6 A schematic diagram of the structure of a three-dimensional model rendering optimization device provided in an embodiment of the present application.

[0079] Figure 7 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0080] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the present invention will be briefly introduced below in combination with the drawings and the description of the embodiments or the prior art. Obviously, the following description of the structures of the drawings is only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these embodiments without creative work. It should be noted that the description of these embodiments is used to help understand the present invention, but does not constitute a limitation of the present invention.

[0081] It should be understood that although the terms first and second, etc. may be used herein to describe various objects, these objects should not be limited by these terms. These terms are only used to distinguish one object from another object. For example, a first object can be referred to as a second object, and similarly, a second object can be referred to as a first object without departing from the scope of the exemplary embodiments of the present invention.

[0082] It should be understood that the term "and / or" that may appear in this document is merely a description of the association relationship between associated objects, indicating that there may be three relationships. For example, A and / or B can indicate three situations: A exists alone, B exists alone, or A and B exist at the same time. For another example, A, B and / or C can indicate the existence of any one of A, B and C or any combination of them. The term " / and" that may appear in this document describes another type of association object relationship, indicating that there may be two relationships. For example, A / and B can indicate two situations: A exists alone or A and B exist at the same time. In addition, the character " / " that may appear in this document generally indicates that the previous and next associated objects are in an "or" relationship.

[0083] Example

[0084] like Figure 1 As shown, the three-dimensional model rendering optimization method provided in the first aspect of this embodiment can be, but is not limited to, executed by a computer device with certain computing resources, such as a cloud server, a personal computer (PC, which refers to a multi-purpose computer with a size, price and performance suitable for personal use; desktops, laptops, small laptops, tablets and ultrabooks are all personal computers), smart phones, personal digital assistants (PDA) or wearable devices. Figure 1 As shown, the three-dimensional model rendering optimization method may include but is not limited to the following steps S1 to S5.

[0085] S1. Preprocessing the component geometric data of the three-dimensional model to be rendered to generate all geometric units, wherein the geometric units include but are not limited to vertex data and the like.

[0086] In step S1, the three-dimensional model to be rendered can be, but is not limited to, a three-dimensional model of a building, wherein the component geometry data is the largest amount of data in the rendering process and is also the core content that affects the rendering performance, specifically including, but not limited to, vertex information / and other basic rendering information used in conventional rendering, wherein the other basic rendering information includes, but is not limited to, normal information, texture information and / or index information (including, but not limited to, vertex index values, normal index values, texture index values ​​and / or other index values, etc.). In order to compress the component geometry data to save the required storage space and reduce the memory and bandwidth requirements, thereby improving the rendering performance, preferably, the component geometry data under the three-dimensional model to be rendered is preprocessed to generate all the geometry units, including, but not limited to, the following steps S11 to S12.

[0087] S11. Traverse the components under the three-dimensional model to be rendered, and obtain geometric data of each component, wherein the geometric data includes but is not limited to vertex information and the like.

[0088] In step S11, the specific method of obtaining the geometric data of each component is an existing conventional technical means. In addition, the geometric data may also include but is not limited to other basic rendering information such as normal information, texture information and / or index information; the vertex information specifically refers to a vertex coordinate data set (a component geometric data may include multiple vertex coordinate data sets).

[0089] S12. For each component, pre-process the corresponding geometric data based on the basic rendering rules and the quantization compression algorithm to obtain at least one corresponding geometric unit, wherein the geometric unit includes but is not limited to vertex data, etc., and the basic rendering rules include but are not limited to the following rules (A1) to (A3):

[0090] (A1) Each geometric unit corresponds to only one material, where the material refers to a color or texture map defined under the three-dimensional model to be rendered;

[0091] (A2) the number of vertices of each geometric unit is less than or equal to a second preset threshold;

[0092] (A3) Each geometric unit contains only one type of rendering primitive, which is a triangle primitive type, a line primitive type or a point primitive type.

[0093] In step S12, the quantization compression algorithm is an existing compression algorithm. The second preset threshold in the above rule (A2) can be preset based on the precision range of the data type; for example, if the data type is ushort type (which is an unsigned 16-bit integer data type with a value range between 0 and 65535), the second preset threshold can be designed to be 65535. Specifically, when the geometric data also includes other basic rendering information such as normal information, texture information and / or index information, the geometric unit may also include but is not limited to other basic rendering data such as normal data, texture data and / or index data. In addition, the geometric unit may also include additional data such as bounding box parameters and the number of vertices.

[0094] S2. Construct a spatial tree based on all the geometric units, in which only leaf nodes are assigned the geometric units.

[0095] In step S2, the spatial tree is a tree network structure consisting of a root node and a plurality of tree nodes and / or leaf nodes. Since the entire technology is relatively sensitive to the length of the bounding box, or can be said to be completely dependent on the length of the bounding box, the space is divided based on the length of the bounding box axis. Specifically, a spatial tree is constructed based on all the geometric units, in which only the leaf nodes are assigned the geometric units, including but not limited to the following steps S21 to S25.

[0096] S21. Create a root node of the space tree and assign all the geometric units to the root node, then use the root node as a tree node and execute step S22.

[0097] S22. According to all geometric units assigned to the tree node, determine whether the fork stop condition is met. If so, use the tree node as a leaf node of the spatial tree and stop forking new child nodes. Otherwise, execute step S23, wherein the fork stop condition includes but is not limited to the following conditions (B1) to (B3):

[0098] (B1) the total number of all geometric units assigned to the tree node is less than or equal to a third preset threshold;

[0099] (B2) the total number of vertices of all geometric units assigned to the tree node is less than or equal to a fourth preset threshold;

[0100] (B3) There is only one geometric unit assigned to the tree node.

[0101] In step S22, the third preset threshold is 1024, and the fourth preset threshold is 65535. In condition (B3), although there is only one geometric unit, the total number of its vertices is less than or equal to 65535 because it is preprocessed based on the basic rendering rules.

[0102] S23. Obtain the length, width and height parameters of the tree node bounding box, and then execute step S24, wherein the tree node bounding box refers to an AABB bounding box used to enclose all geometric units assigned to the tree node.

[0103] In step S23, the AABB bounding box is a bounding box obtained by enclosing a number of geometric units using the existing AABB (Axis-aligned bounding box) bounding box algorithm. The enclosing relationship between the AABB bounding box and the geometric units can be exemplified by: Figure 2 As shown, the length, width and height parameters of the tree node bounding box can be conventionally obtained.

[0104] S24. Create the first child node and the second child node of the tree node, and for each geometric unit assigned to the tree node, if the length, width and height parameters of the corresponding unit bounding box meet the following conditions: UBL x >λ×BL x 、UBL y >λ×BL y and / or UBL z >λ×BL z , the corresponding unit is transferred and assigned to the first child node, otherwise the corresponding unit is transferred and assigned to the second child node, and then step S25 is executed, wherein the unit bounding box refers to the AABB bounding box used to enclose the geometric unit, UBL x Indicates the length parameter in the length, width and height parameters of the unit bounding box, BL x Represents the length parameter in the length, width and height parameters of the tree node bounding box, UBL y Indicates the width parameter in the length, width and height parameters of the unit bounding box, BL y Represents the width parameter in the length, width and height parameters of the tree node bounding box, UBL z Indicates the height parameter in the length, width and height parameters of the unit bounding box, BL z It represents the height parameter in the length, width and height parameters of the tree node bounding box, and λ represents a pure decimal between 0.25 and 0.4.

[0105] In the step S24, the first sub-node is used to store a larger geometric unit, and the second sub-node is used to store a smaller geometric unit. In addition, specifically, λ can be taken as one third, for example.

[0106] S25. Take the first child node and the second child node as a new tree node respectively, and return to execute step S22.

[0107] Therefore, based on the aforementioned steps S21 to S25, a spatial binary tree will be generated, and all the geometric units will eventually be allocated to leaf nodes (that is, only leaf nodes will have geometric units), and then corresponding combined blocks to be rendered can be generated for each leaf node.

[0108] S3. For each leaf node on the spatial tree, generate a corresponding combined block to be rendered according to all the geometric units assigned to the corresponding node, wherein the combined block to be rendered includes but is not limited to a vertex data set.

[0109] In step S3, since individual components are not considered in the spatial division process, the geometric unit bounding box on each leaf node may contain multiple different components or even a part of a component (such as Figure 3The purpose of constructing the combination block is to combine their data into one, making it a whole without distinguishing each other, so that they can be rendered as a whole later. In other words, after the combination block is constructed, each combination block is an independent minimum unit in the final rendering; if a three-dimensional model to be rendered finally generates 10 combination blocks to be rendered, when rendering this model, it is to call the rendering command (such as Opengl, OpenglES or WebGL, etc.) to render these 10 combination blocks one by one. Specifically, for each leaf node on the spatial tree, a corresponding combination block to be rendered is generated according to all the geometric units assigned to the corresponding node, including but not limited to the following steps S31 to S35.

[0110] S31. For a leaf node on the spatial tree, perform a rendering error check on the basic rendering data in all the geometric units allocated to the corresponding node.

[0111] In the step S31, the basic rendering data includes but is not limited to vertex data and / or other basic rendering data such as normal data, texture data and / or index data. Since the present embodiment designs a special data structure, it is necessary to ensure that the content of each data structure is consistent. Only consistency can ensure that there will be no problems when the data is rendered later (if it cannot be guaranteed, crashes or rendering failures may occur later). In order to ensure that subsequent processing and rendering will not go wrong, preferably, for a leaf node on the spatial tree, a rendering error check is performed on the basic rendering data in all the geometric units assigned to the corresponding node, including but not limited to the following steps S311 to S313.

[0112] S311. For a leaf node on the spatial tree, if it is found that the vertex data in all the geometric units allocated to the corresponding node are empty, it is determined that there is a vertex rendering error, otherwise it is determined that there is no vertex rendering error.

[0113] S312. For a leaf node on the spatial tree, if it is found that the texture data in all the geometric units allocated to the corresponding node is not empty, continue to check whether the number of textures obtained based on the texture data is consistent with the number of vertices obtained based on the vertex data in all the geometric units allocated to the corresponding node. If so, the texture rendering is determined to be correct. Otherwise, it is determined that there is a texture rendering error, and the default data is used to supplement the missing texture data or vertex data. The texture rendering is not incorrect until it is found that the number of textures is consistent with the number of vertices.

[0114] In the step S312, the following default data: (0.0, 0.0, 0.0) may be used to supplement the missing vertex data, and the following default data: (0.0, 0.0) may be used to supplement the missing texture data.

[0115] S313. For a leaf node on the spatial tree, if it is found that the normal data in all the geometric units assigned to the corresponding node is not empty, continue to check whether the number of normals obtained based on the normal data is consistent with the number of vertices obtained based on the vertex data in all the geometric units assigned to the corresponding node. If so, it is determined that the normal rendering is correct. Otherwise, it is determined that there is a normal rendering error, and the default data is used to supplement the missing normal data or vertex data. Until it is found that the number of normals is consistent with the number of vertices, the normal rendering is determined to be correct.

[0116] In the step S313, the following default data (0.0, 0.0, 0.0) may be used to supplement the missing vertex data, and the following default data (0.0, 0.0, 1.0) may be used to supplement the missing normal data.

[0117] In the step S31, it is also considered that index data may or may not exist. Therefore, if it is found that all the geometric units assigned to the leaf node have no index data, then the subsequently generated combined blocks to be rendered will also have no index data; and if at least one geometric unit has index data, then the subsequently generated combined blocks to be rendered must have index data, and the default index value can be consistent with the array subscript index value where the vertex is located.

[0118] S32. After checking that there are no errors, the vertex data quantization compression parameters are calculated according to the upper and lower limits of the range of the leaf node bounding box and the upper and lower limits of the precision range of the vertex data compression target type: vertex compression offset value, vertex compression scaling value, vertex decompression offset value and vertex decompression release value, wherein the leaf node bounding box refers to the AABB bounding box used to enclose all the geometric units assigned to the certain leaf node, and the vertex compression offset value PackOffset, the vertex compression scaling value PackScale, the vertex decompression offset value UnpackOffset and the vertex decompression release value UnpackScale are calculated as follows:

[0119]

[0120] In the formula, BOX max Indicates the upper limit of the bounding box of the leaf node, BOX min Indicates the lower limit of the bounding box of the leaf node, Compress maxIndicates the upper limit of the precision range of the vertex data compression target type. min Indicates the lower limit of the precision range of the vertex data compression target type.

[0121] In step S32, the error-free check includes but is not limited to vertex rendering error-free, texture rendering error-free, and normal rendering error-free, etc. The upper and lower limits of the range of the leaf node bounding box are also the upper and lower limits of the vertex range (the upper limit is the maximum value of the vertex in the vertex data of all the geometric units assigned to the certain leaf node, and the lower limit is the minimum value of the vertex in the vertex data of all the geometric units assigned to the certain leaf node). Generally, vertex data is stored using single-precision floating-point type (i.e., float type). Specifically, the compressed data type can be determined according to the error range allowed by the vertex range length (i.e., the vertex range upper limit minus the vertex range lower limit) (i.e., one of four types, namely, uchar type, char type, ushort type, and short type, is selected as the vertex data compression target type); in order to facilitate calculation, this embodiment selects unsigned integer type: uchar type or ushort type as the vertex data compression target type, and because the single-precision floating-point type occupies 4 bytes when stored, the uchar type (whose precision range upper limit is 255 and precision range lower limit is 0) occupies 1 byte, and the ushort type (whose precision range upper limit is 65535 and precision range lower limit is 0) occupies 2 bytes, so a lot of space can be saved (i.e., the compression rate can reach 25% or 50%).

[0122] S33. For each vertex data in all the geometric units assigned to the leaf node, apply the vertex compression offset value PackOffset and the vertex compression scaling value PackScale, and calculate the corresponding compressed vertex data Position according to the following formula: compress :

[0123] Position compress =(Position origin +PackOffset)×PackScale

[0124] Where, Position origin Represents vertex data before compression.

[0125] S34. According to the array order of the vertex data in all the geometric units allocated to the leaf nodes, the compressed vertex data corresponding to the vertex data one by one are added to the vertex data set in sequence.

[0126] In the step S34, the array order specifically refers to the arrangement order of the arrays to which the vertices belong.

[0127] S35. Generate a certain leaf node and a to-be-rendered combined block including but not limited to the vertex data set and the decompressed offset value UnpackOffset and the decompressed scale value UnpackScale, wherein the decompressed offset value UnpackOffset and the decompressed scale value UnpackScale are used to decompress and restore the respective vertex data according to the following formula during rendering:

[0128] Position o ' rigin =Position compress ×UnpackScale+UnpackOffset

[0129] Where, Position o ' rigin Represents the restored vertex data.

[0130] In the step S3, considering that the basic rendering data in all the geometric units assigned to the leaf node may also include texture data, in order to quantize and compress this data, preferably, after checking for errors, the method also includes but is not limited to the following steps S311 to S313.

[0131] S311. According to the upper and lower limits of the range of texture data in all the geometric units assigned to the certain leaf node and the upper and lower limits of the precision range of the texture data compression target type, the texture data quantization compression parameters are calculated: texture compression offset value, texture compression scaling value, texture decompression offset value and texture decompression release value, wherein the calculation formulas of the texture compression offset value PackOffset", the texture compression scaling value PackScale", the texture decompression offset value UnpackOffset" and the texture decompression release value UnpackScale" are as follows:

[0132]

[0133] In the formula, Texture max Indicates the upper limit of the range of texture data in all the geometric units assigned to the leaf node. min Indicates the upper limit of the range of texture data in all the geometric units assigned to the leaf node, Compress max Indicates the upper limit of the precision range of the texture data compression target type, Compress minIndicates the lower limit of the precision range of the texture data compression target type.

[0134] In the step S311, the upper and lower limits of the range of the texture data are the maximum and minimum values ​​of the texture coordinate data. The texture data compression target type can also determine the compressed data type (i.e., select one of the four types of uchar type, char type, ushort type and short type as the texture data compression target type) according to the error range allowed by the texture range length (i.e., the upper limit of the range of the texture data minus the lower limit of the range of the texture data).

[0135] S312. For each texture data in all the geometric units assigned to the leaf node, apply the texture compression offset value PackOffset" and the texture compression scaling value PackScale" to calculate the corresponding compressed texture data Texture according to the following formula: compress :

[0136] Texture compress =(Texture origin +PackOffset″)×PackScale″

[0137] In the formula, Texture origin Represents texture data before compression.

[0138] S313. According to the array order of the texture data in all the geometric units allocated to the leaf nodes, the compressed texture data corresponding to the texture data one by one are added to the texture data set in sequence.

[0139] S314. Add the texture data set and the texture decompression offset value UnpackOffset" and the texture decompression scale value UnpackScale" to the to-be-rendered combined block of the leaf node, wherein the decompression offset value UnpackOffset" and the decompression scale value UnpackScale" are used to decompress and restore the various texture data according to the following formula during rendering:

[0140] Texture o ' rigin =Texture compress ×UnpackScale″+UnpackOffset″

[0141] In the formula, Texture o ' rigin Represents the restored texture data.

[0142] In the step S3, it is considered that the basic rendering data in all the geometric units assigned to the leaf node may also include normal data, and since the normal data itself is normalized coordinate data (-1.0~1.0) and the accuracy requirement is not high, it can be directly compressed into the accuracy range of the char type. Therefore, in order to quantize and compress this data, after checking that there are no errors, when the normal data compression target type is char type, the method also includes but is not limited to the following steps S321~S323.

[0143] S321. For each normal data in all the geometric units assigned to the leaf node, the corresponding compressed normal data Normal is calculated according to the following formula: compress :

[0144] Normal compress = char(Normal origin ×127)

[0145] In the formula, Normal origin represents normal data before compression, and char() represents a conversion function corresponding to the char type.

[0146] S322. According to the array order of the normal data in all the geometric units allocated to the leaf nodes, the compressed normal data corresponding to the normal data are added to the normal data set in sequence.

[0147] S323. Add the normal data set to the to-be-rendered combination block of the certain leaf node.

[0148] After step S323, the normal data are obtained by decompressing and restoring according to the following formula during rendering:

[0149] Normal o ' rigin =float(Normal compress ÷127)

[0150] In the formula, Normal o ' rigin Represents the restored normal data, and float() represents the conversion function corresponding to the float type.

[0151] In the step S3, it is considered that the basic rendering data in all the geometric units assigned to the leaf node may also include index data, and since the index represents the subscript index value of the vertex array, its value range depends on the number of vertices. Subsequently, it is only necessary to force the index value to be converted into the corresponding data type according to the total number of vertices contained in the combined block after the merging. Therefore, in order to quantize and compress this data, after adding each compressed vertex data corresponding to each vertex data one by one to the vertex data set in turn, the method also includes but is not limited to the following steps S331 to S334.

[0152] S331. Count and obtain the total number N of vertices in the vertex data set.

[0153] S332. According to the total number of vertices N, convert the vertex index data in all the geometric units assigned to the leaf node according to the following conversion methods (C1) to (C1):

[0154] (C1) If the total number of vertices N is less than or equal to 255, convert the vertex index data into uchar type data;

[0155] (C2) if the total number of vertices N is greater than 255 and less than or equal to 65535, convert the vertex index data into ushort type data;

[0156] (C3) If the total number of vertices N is greater than 65535, the vertex index data is converted into uint type data.

[0157] S333. For each of the geometric units assigned to the leaf node, obtain the vertex data group number M of the compressed vertex data group obtained based on the corresponding vertex data group in the vertex data set, and add the vertex data group number M to the converted vertex index data corresponding to the vertex data group to obtain new vertex index data corresponding to the compressed vertex data group.

[0158] S334. Add each of the new vertex index data to the vertex index data set.

[0159] S335. Add the vertex index data set to the to-be-rendered combination block of the certain leaf node.

[0160] S4. Generate a set of geometric primitive groups according to the vertex data set of the combined block to be rendered, and add the set of geometric primitive groups to the combined block to be rendered, wherein the set of geometric primitive groups includes at least one geometric primitive group arranged in descending order according to primitive size.

[0161] In step S4, after the combined block is generated, in order to realize pixel culling in the real-time rendering stage, the most critical processing of the combined block data is required, that is, geometric primitive grouping: Figure 4 As shown, first, the most basic geometric primitive rendering data (such as triangle primitives) in the combined block are sorted from large to small according to the diameter of their enclosing spheres (after sorting, the index value needs to be updated so that the minimum index value corresponds to the largest triangle, and the maximum index value corresponds to the smallest triangle); then, the primitive units are grouped according to a fixed size range to obtain primitive groups; each primitive group contains the index start value and end value of all the primitive units under it (so that when drawing a combined block, the required index range value can be passed in through the drawing command to accurately draw the required primitive group: for example, if you want to draw the following Figure 4 For the second primitive group under the combined block shown, you only need to know the index starting value startIndex and the ending value endIndex of the second primitive group, and call the drawing command drawCombineBlock(startIndex, endIndex) to draw the content of any primitive group in this combined block). In order to quickly complete the task of grouping geometric primitives, preferably, a geometric primitive group set is generated according to the vertex data set of the combined block to be rendered, including but not limited to the following steps S41 to S48.

[0162] S41. Generate all geometric primitives according to the vertex data set in the combined block to be rendered, and then execute step S42. The geometric primitives correspond one-to-one to the vertex data groups in the vertex data set.

[0163] In the step S41, the geometric primitives are mainly of three types: triangle surface primitives, line primitives and point primitives. They can be generated directly through vertex data or indirectly through index values ​​to find vertex data; for example, triangle surface primitives are the most common geometric primitives. Every three index values ​​correspond to a triangle vertex data. A geometric primitive can be generated by finding the corresponding vertex array index through the index value, obtaining three vertex data, and calculating the diagonal length of its bounding box as its size; the generation logic of line primitives is the same, which will not be repeated here.

[0164] S42. Arrange all the geometric primitives in order from large to small according to the size of the primitives to obtain a geometric primitive sequence, and then execute step S43.

[0165] S43. Traverse the sequence number of geometric primitives Initialize to 1, and also traverse the size interval boundary sequence number Initialize to Then, step S44 is performed, wherein: Represents the total number of boundary values ​​in a sequence of size interval boundary values ​​arranged in ascending order.

[0166] In step S43, the size interval boundary value sequence can be pre-set based on the modeling experience of building three-dimensional models, for example, it is designed as:

[0167] {0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7 ,2.8,2.9,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0,5.5,6.0,6.5,7.0,7.5,8.0, 8.5,9.0,9.5,10.0,20.0,30.0,40.0,50.0,60.0,70.0,80.0,90.0,100.0,1000.0,FLT_MAX}

[0168] The unit of the size interval boundary value in the above sequence is meter, and FLT_MAX represents the maximum size interval boundary value, so The value is 72.

[0169] S44. Determine the first Is the size of the geometric primitive smaller than the first value in the sequence of boundary values ​​of the size interval? If yes, execute step S45; otherwise, execute step S46.

[0170] S45.Judgment Is it equal to 1? If so, execute step S48. Otherwise, Decrement by 1, and then return to execute step S44.

[0171] S46. Determine whether the A geometric tuple is created for each size interval boundary value. If so, the first The geometric primitive is added to the geometric primitive group, and then step S47 is executed, otherwise for the first Create a new geometric primitive group with the size interval boundary value and set the The geometric primitives are added to the new geometric primitive group, and then step S47 is executed.

[0172] In the step S46, since the maximum size of the geometric primitive group is an important parameter required in the subsequent pixel culling process, it is further preferred that the maximum size of the geometric primitive group is an important parameter required in the subsequent pixel culling process. After adding the first geometric primitive to the new geometric primitive group, the method further comprises: adding the first The size value of the geometric primitives is used as the maximum size of the new geometric primitive group, and it can also be When greater than 1, the first The size value of the geometric primitives is taken as the minimum size value of the most recently created geometric primitive group whose creation time is prior to the new geometric primitive group.

[0173] S47. Judgment Is it equal to If yes, then execute step S48, otherwise Increment by 1, and then return to step S44, where: Represents the total number of primitives in the sequence of geometric primitives.

[0174] S48. Arrange all geometric primitive groups in order from earliest to latest according to the creation time to obtain a geometric primitive group set, wherein the geometric primitive group set contains at least one geometric primitive group arranged in order from largest to smallest according to the primitive size.

[0175] Based on the above steps S41 to S48, the geometric primitive group can also include at least one geometric primitive arranged in order from large to small according to the primitive size. In addition, in order to reorganize the index (i.e., regenerate an index value array for the combined block, the index value remains unchanged, but the order is adjusted), after all the geometric primitive groups are arranged in order from early to late according to the creation time to obtain a geometric primitive group set, the method also includes but is not limited to: for each geometric primitive group in the geometric primitive group set, create a corresponding primitive index data group, add the primitive index value of each geometric primitive in the corresponding group to the primitive index data group, and also record the start position and end position of the corresponding group under the index data set.

[0176] S5. When rendering the three-dimensional model to be rendered, traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in order from large to small according to the primitive size: according to the camera's nearest point and the maximum size of the geometric primitive group currently being traversed, apply the view matrix and projection matrix of the virtual camera to calculate the screen projection size value corresponding to the geometric primitive group currently being traversed, and determine whether the screen projection size value is greater than or equal to zero and less than a first preset threshold value. If so, terminate the rendering of the geometric primitive group currently being traversed and all geometric primitive groups that are not currently traversed, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combined block to be rendered and closest to the virtual camera.

[0177] In step S5, since the data structure of the combination block to be rendered is available, the rendering content of each combination block can be dynamically adjusted according to the distance of the virtual camera through pixel culling technology. Figure 5 As shown in the figure, the same tree in the four pictures is used to give the simplest explanation of pixel culling: the closer the eyes are to the tree, the bigger the tree is, and the farther the eyes are from the tree, the smaller the tree is. This is the same as the rule in the real world. The process of any rendering is to turn the tree into a two-dimensional picture and display it on the screen. The tree is finally displayed to people through the pixels on the screen. So the bigger the tree is, the more pixels it occupies, and the smaller the tree is, the smaller the pixels it occupies. When its pixels are so small that they are basically invisible, the tree can be ignored and no longer rendered (now the screen devices have very high pixels, generally 3 or 5 pixels can be ignored). Ignore and treat them as invisible); pixel culling uses this principle to process each frame of real-time rendering (generally, if the camera is not moving, it can be ignored, but it will be processed only when the camera moves). The primitive groups that occupy very small pixels are eliminated and no longer drawn, which improves rendering efficiency by reducing the final hardware drawing amount. Because there are many components in the 3D model of architecture, such as electromechanical sprinkler heads, pipe fittings, steel bar screws, nuts, and conventional doors and windows and other small parts, the more sophisticated the model, the more small and miscellaneous things there are, and the efficiency improved by using pixel culling is very large. Therefore, it is particularly suitable for rendering 3D models of architecture.

[0178] In step S5, the closest point of the camera, that is, the point of the bounding box of the combined block to be rendered that is closest to the virtual camera, is used as the only reference point for calculating the screen projection size value of the entire combined block to be rendered; considering that pixel culling directly ignores drawing, which has a greater impact on the display result, normally its judgment condition should be as strict as possible. This point is closest to the camera, and using this point as the basis for judgment, the pixel size projected onto the screen is also the largest (projection perspective is larger when near and smaller when far, and is not affected by orthogonal perspective). If the pixel size obtained based on the maximum size can be ignored, then there is definitely no problem in ignoring the drawing.

[0179] In step S5, the calculation process of the screen projection size value is as follows: first, through the position point P space (i.e. the closest point of the camera) to obtain a plane Plane parallel to the camera plane; then, by using the size (i.e. the maximum size of the geometric primitive group currently being traversed) to obtain the plane Plane parallel to the camera plane; space As the center, find two points P1 in any direction of the plane Plane space and P2 space ; Then P1 space and P2 space The corresponding device normalized coordinate value P1 is obtained by transforming the camera view matrix and the projection matrix respectively. normlized and P2 normalized ;Finally, the normalized coordinate value P1 normlized and P2 normalized Convert to the corresponding actual screen pixel size coordinate value P1 screen and P2 screen , these two screen pixel size coordinate points P1 screen and P2 screen The distance value is the final screen projection size value S screen In addition, the first preset threshold value can be preset according to actual needs, for example, it is designed to be 4; the first threshold value is also closely related to the screen resolution and screen size. Some displays have very high resolutions, but the screens are relatively small. In this case, the threshold value can be set higher. On the contrary, the display resolution is relatively low and the screen is relatively large. In this case, the threshold value can be set lower.

[0180] In the step S5, the processing of each combined block to be rendered can be further optimized (that is, some special cases can be separately proposed for processing in advance). Preferably, each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered is traversed in sequence from large to small according to the primitive size, including but not limited to the following optional steps S51 to S53.

[0181] S51. According to the camera's nearest point and the maximum size of the first geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, apply the view matrix and projection matrix of the virtual camera to calculate the screen projection size value corresponding to the first geometric primitive group, and determine whether the screen projection size value is less than zero. If so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size; otherwise, continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to the point determined according to the vertex data set of the combined block to be rendered and closest to the virtual camera.

[0182] In the step S51, if the screen projection size value is less than zero, it indicates that the virtual camera is inside the combination block, so the entire combination block is drawn without considering culling.

[0183] S52. According to the camera's nearest point and the maximum size of the first geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the first geometric primitive group, and determine whether the screen projection size value is greater than a first preset threshold value. If so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size; otherwise, continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combined block to be rendered and closest to the virtual camera.

[0184] S53. According to the camera's nearest point and the maximum size of the last geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, apply the view matrix and projection matrix of the virtual camera to calculate the screen projection size value corresponding to the last geometric primitive group, and determine whether the screen projection size value is less than a first preset threshold value. If so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size; otherwise, continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combined block to be rendered and closest to the virtual camera.

[0185] In step S5, after the above processing, a sentinel primitive group PG_sentinel under the combination block can be obtained, the primitive units contained in the primitive group in front of it need to be drawn, and the primitive units contained in the primitive group behind it do not need to be drawn; each primitive group contains the starting position startIndex and the ending position endIndex of the primitive under the index set, then the starting position startIndex under the first primitive group can be taken, and the ending position endIndex under PG_sentinel can be taken. The vertex data, normal data, and texture data between the starting position and the ending position are the contents that need to be drawn under the combination block. Since the indexes under the combination block have been reorganized before, and through the above various designs, the drawing of the primitive group must be continuous, so the indexes that need to be drawn in the end are also continuous, and when drawing, just pass the parameters corresponding to the drawing command. Take the two most commonly used drawing commands in WebGL as examples: (1) voidgl.drawElements(mode, count, type, offset), where count represents the number of elements to be rendered, that is, the number to be drawn, corresponding to the difference between the end position and the start position of the previous index endIndex-startIndex, and offset represents the byte offset of the specified element array buffer, that is, the starting position of the drawing, corresponding to the start position of the previous index startIndex; (2) void gl.drawArrays(mode, first, count), where first is similar to the above offset, and count is similar to the above count. In addition, pixel culling is triggered by camera changes. If the camera does not change, pixel culling can be omitted and the previous frame processing result can be used to continue rendering; if the camera changes, all the combination blocks must be processed again according to the above steps to obtain new data for drawing; before processing, remember to reset the relevant records of the combination blocks and re-obtain the sentinel primitive group PG_sentinel and related data.

[0186] Therefore, based on the three-dimensional model rendering optimization method described in the aforementioned steps S1 to S5, a new solution for three-dimensional model rendering optimization based on pixel culling rendering is provided, that is, firstly, data processing is performed on the component geometric data under the three-dimensional model to be rendered, and all geometric units, a spatial tree with only leaf nodes assigned with geometric units, and a combination block to be rendered corresponding to each leaf node and containing a vertex data set and a geometric primitive group set are generated in sequence, and then when rendering the model, each geometric primitive group in the geometric primitive group set of the combination block to be rendered is traversed in order from large to small according to the primitive size: according to the maximum size of the camera's nearest point and the geometric primitive group currently being traversed, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the geometric primitive group, and finally, according to the comparison result between the size value and the preset threshold, it is determined whether to render the geometric primitive group. In this way, from the perspective of screen pixel occupancy, the three-dimensional model content with very small screen pixel occupancy can be identified and its rendering can be shielded, and then after the volume of the three-dimensional model is increased, the rendering efficiency can be greatly improved, which is convenient for practical application and promotion.

[0187] like Figure 6 As shown, the second aspect of this embodiment provides a virtual device for implementing the three-dimensional model rendering optimization method described in the first aspect, comprising a geometric unit generation module, a space tree construction module, a combination block generation module, a geometric primitive grouping module and a primitive group rendering module which are sequentially connected in communication;

[0188] The geometric unit generation module is used to pre-process the component geometric data under the three-dimensional model to be rendered to generate all geometric units, wherein the geometric units include vertex data;

[0189] The spatial tree construction module is used to construct a spatial tree in which only leaf nodes are assigned with the geometric units according to all the geometric units;

[0190] The combined block generation module is used to generate a corresponding combined block to be rendered for each leaf node on the spatial tree according to all the geometric units assigned to the corresponding node, wherein the combined block to be rendered includes a vertex data set;

[0191] The geometric primitive grouping module is used to generate a geometric primitive group set according to the vertex data set of the combined block to be rendered, and add the geometric primitive group set to the combined block to be rendered, wherein the geometric primitive group set includes at least one geometric primitive group arranged in descending order according to primitive size;

[0192] The primitive group rendering module is used to traverse each geometric primitive group in the geometric primitive group set of the combination block to be rendered in descending order according to the primitive size when rendering the three-dimensional model to be rendered: according to the camera's nearest point and the maximum size of the geometric primitive group currently being traversed, apply the view matrix and projection matrix of the virtual camera to calculate the screen projection size value corresponding to the geometric primitive group currently being traversed, and determine whether the screen projection size value is greater than or equal to zero and whether it is less than a first preset threshold value. If so, terminate the rendering of the geometric primitive group currently being traversed and all geometric primitive groups that are not currently traversed, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combination block to be rendered and closest to the virtual camera.

[0193] The working process, working details and technical effects of the aforementioned device provided in the second aspect of this embodiment can be referred to the three-dimensional model rendering optimization method described in the first aspect, and will not be repeated here.

[0194] like Figure 7 As shown, the third aspect of this embodiment provides a computer device for executing the three-dimensional model rendering optimization method as described in the first aspect, including a memory, a processor and a transceiver that are sequentially connected in communication, wherein the memory is used to store a computer program, the transceiver is used to send and receive messages, and the processor is used to read the computer program and execute the three-dimensional model rendering optimization method as described in the first aspect. For example, the memory may include, but is not limited to, a random access memory (Random-Access Memory, RAM), a read-only memory (Read-Only Memory, ROM), a flash memory (Flash Memory), a first-in-first-out memory (First Input First Output, FIFO) and / or a first-in-last-out memory (First Input Last Output, FILO), etc.; the processor may include, but is not limited to, a microprocessor of the STM32F105 series. In addition, the computer device may also include, but is not limited to, a power module, a display screen and other necessary components.

[0195] The working process, working details and technical effects of the aforementioned computer device provided in the third aspect of this embodiment can be found in the three-dimensional model rendering optimization method described in the first aspect, and will not be repeated here.

[0196] In a fourth aspect of this embodiment, there is provided a computer-readable storage medium storing instructions including the three-dimensional model rendering optimization method as described in the first aspect, that is, the computer-readable storage medium stores instructions, and when the instructions are run on a computer, the three-dimensional model rendering optimization method as described in the first aspect is executed. The computer-readable storage medium refers to a carrier for storing data, which may include but is not limited to computer-readable storage media such as floppy disks, optical disks, hard disks, flash memories, USB flash drives, and / or memory sticks, and the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.

[0197] The working process, working details and technical effects of the aforementioned computer-readable storage medium provided in the fourth aspect of this embodiment can be referred to the three-dimensional model rendering optimization method described in the first aspect, and will not be repeated here.

[0198] In a fifth aspect, the present embodiment provides a computer program product, including a computer program or instructions, wherein the computer program or instructions, when executed by a computer, implements the three-dimensional model rendering optimization method as described in the first aspect. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.

[0199] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A three-dimensional model rendering optimization method, characterized in that: include: Preprocessing the component geometric data under the three-dimensional model to be rendered to generate all geometric units, wherein the geometric units include vertex data; Constructing a spatial tree in which only leaf nodes are assigned with the geometric units according to all the geometric units; For each leaf node on the spatial tree, generating a corresponding combination block to be rendered according to all the geometric units assigned to the corresponding node, wherein the combination block to be rendered includes a vertex data set; Generate a geometric primitive group set according to the vertex data set of the combined block to be rendered, and add the geometric primitive group set to the combined block to be rendered, wherein the geometric primitive group set includes at least one geometric primitive group arranged in descending order according to primitive sizes; When rendering the three-dimensional model to be rendered, each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered is traversed in order from large to small according to the primitive size: according to the camera's nearest point and the maximum size of the geometric primitive group currently being traversed, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the geometric primitive group currently being traversed, and determine whether the screen projection size value is greater than or equal to zero and less than a first preset threshold value. If so, terminate the rendering of the geometric primitive group currently being traversed and all geometric primitive groups that are not currently traversed, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combined block to be rendered and closest to the virtual camera.

2. The three-dimensional model rendering optimization method according to claim 1, characterized in that: Preprocess the component geometry data of the 3D model to be rendered according to the basic rendering rules to generate all the geometry units, including: Traversing the components under the three-dimensional model to be rendered, and obtaining geometric data of each component, wherein the geometric data contains vertex information; For each component, the corresponding geometric data is preprocessed based on the basic rendering rules and the quantization compression algorithm to obtain at least one corresponding geometric unit, wherein the geometric unit includes vertex data, and the basic rendering rules include the following rules (A1) to (A3): (A1) Each geometric unit corresponds to only one material, where the material refers to a color or texture map defined under the three-dimensional model to be rendered; (A2) the number of vertices of each geometric unit is less than or equal to a second preset threshold; (A3) Each geometric unit contains only one type of rendering primitive, which is a triangle primitive type, a line primitive type or a point primitive type.

3. The three-dimensional model rendering optimization method according to claim 1, characterized in that: Constructing a space tree in which only leaf nodes are assigned the geometric units according to all the geometric units includes the following steps S21 to S25: S21. Create a root node of the space tree, and assign all the geometric units to the root node, and then use the root node as a tree node to execute step S22; S22. According to all the geometric units assigned to the tree node, determine whether the fork stop condition is satisfied. If so, use the tree node as a leaf node of the spatial tree and stop forking new child nodes. Otherwise, execute step S23, wherein the fork stop condition includes the following conditions (B1) to (B3): (B1) the total number of all geometric units assigned to the tree node is less than or equal to a third preset threshold; (B2) the total number of vertices of all geometric units assigned to the tree node is less than or equal to a fourth preset threshold; (B3) There is only one geometric unit assigned to the tree node; S23. Obtain the length, width and height parameters of the tree node bounding box, and then execute step S24, wherein the tree node bounding box refers to an AABB bounding box used to enclose all geometric units assigned to the tree node; S24. Create the first child node and the second child node of the tree node, and for each geometric unit assigned to the tree node, if the length, width and height parameters of the corresponding unit bounding box meet the following conditions: UBL x >λ×BL x 、UBL y >λ×BL y and / or UBL z >λ×BL z , the corresponding unit is transferred and assigned to the first child node, otherwise the corresponding unit is transferred and assigned to the second child node, and then step S25 is executed, wherein the unit bounding box refers to the AABB bounding box used to enclose the geometric unit, UBL x Indicates the length parameter in the length, width and height parameters of the unit bounding box, BL x Represents the length parameter in the length, width and height parameters of the tree node bounding box, UBL y Indicates the width parameter in the length, width and height parameters of the unit bounding box, BL y Represents the width parameter in the length, width and height parameters of the tree node bounding box, UBL z Indicates the height parameter in the length, width and height parameters of the unit bounding box, BL z represents the height parameter in the length, width and height parameters of the tree node bounding box, and λ represents a pure decimal between 0.25 and 0.4; S25. Take the first child node and the second child node as a new tree node respectively, and return to execute step S22.

4. The 3D model rendering optimization method according to claim 1, characterized in that: For each leaf node on the spatial tree, a corresponding combined block to be rendered is generated according to all the geometric units assigned to the corresponding node, including: For a leaf node on the spatial tree, performing a rendering error check on basic rendering data in all the geometric units allocated to the corresponding node; After checking that there are no errors, the vertex data quantization compression parameters are calculated according to the upper and lower limits of the range of the leaf node bounding box and the upper and lower limits of the precision range of the vertex data compression target type: vertex compression offset value, vertex compression scaling value, vertex decompression offset value and vertex decompression release value, wherein the leaf node bounding box refers to the AABB bounding box used to enclose all the geometric units assigned to the certain leaf node, and the vertex compression offset value PackOffset, the vertex compression scaling value PackScale, the vertex decompression offset value UnpackOffset and the vertex decompression release value UnpackScale are calculated as follows: In the formula, BOX max Indicates the upper limit of the bounding box of the leaf node, BOX min Indicates the lower limit of the bounding box of the leaf node, Compress max Indicates the upper limit of the precision range of the vertex data compression target type, Compress min Indicates the lower limit of the precision range of the vertex data compression target type; For each vertex data in all the geometric units assigned to the leaf node, the vertex compression offset value PackOffset and the vertex compression scaling value PackScale are applied to calculate the corresponding compressed vertex data Position according to the following formula: compress : Position compress =(Position origin +PackOffset)×PackScale Where, Position origin Indicates vertex data before compression; According to the array order of the vertex data in all the geometric units allocated to the leaf nodes, the compressed vertex data corresponding to the vertex data are sequentially added to the vertex data set; Generate a certain leaf node and a to-be-rendered combined block including the vertex data set and the decompressed offset value UnpackOffset and the decompressed scale value UnpackScale, wherein the decompressed offset value UnpackOffset and the decompressed scale value UnpackScale are used to decompress and restore the respective vertex data according to the following formula during rendering: Position o ′ rigin =Position compress ×UnpackScale+UnpackOffset Where, Position o ' rigin Represents the restored vertex data.

5. The 3D model rendering optimization method according to claim 1, characterized in that: Generating a set of geometric primitives according to the vertex data set of the combined block to be rendered includes the following steps S41 to S48: S41. Generate all geometric primitives according to the vertex data set in the combined block to be rendered, and then execute step S42. The geometric primitives correspond one-to-one to the vertex data groups in the vertex data set; S42. Arrange all the geometric primitives in descending order according to the size of the primitives to obtain a geometric primitive sequence, and then execute step S43; S43. Traverse the sequence number of geometric primitives Initialize to 1, and also traverse the size interval boundary sequence number Initialize to Then, step S44 is performed, wherein: It indicates the total number of boundary values ​​in the sequence of boundary values ​​of the size interval arranged in ascending order of numerical value; S44. Determine the first Is the size of the geometric primitive smaller than the first value in the sequence of boundary values ​​of the size interval? If yes, execute step S45, otherwise execute step S46; S45.Judgment Is it equal to 1? If so, execute step S48. Otherwise, Decrement by 1, and then return to execute step S44; S46. Determine whether the A geometric tuple is created for each size interval boundary value. If so, the first The geometric primitive is added to the geometric primitive group, and then step S47 is executed, otherwise for the first Create a new geometric primitive group with the size interval boundary value and set the The geometric primitives are added to the new geometric primitive group, and then step S47 is executed; S47. Judgment Is it equal to If yes, then execute step S48, otherwise Increment by 1, and then return to step S44, where: The total number of primitives representing the geometric primitive sequence; S48. Arrange all geometric primitive groups in order from earliest to latest according to the creation time to obtain a geometric primitive group set, wherein the geometric primitive group set contains at least one geometric primitive group arranged in order from largest to smallest according to the primitive size.

6. The 3D model rendering optimization method according to claim 1, characterized in that: The geometric primitive groups in the set of geometric primitive groups of the to-be-rendered combined block are sequentially traversed in descending order of primitive size, including: According to the camera's nearest point and the maximum size of the first geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the first geometric primitive group, and determine whether the screen projection size value is less than zero. If so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size; otherwise, continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to the point determined according to the vertex data set of the combined block to be rendered and closest to the virtual camera; And / or, according to the camera's nearest point and the maximum size of the first geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, the view matrix and the projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the first geometric primitive group, and determine whether the screen projection size value is greater than a first preset threshold value, if so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, otherwise continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to a point determined according to the vertex data set of the combined block to be rendered and closest to the virtual camera; And / or, based on the camera's nearest point and the maximum size of the last geometric primitive group in the set of geometric primitive groups of the combined block to be rendered, the view matrix and projection matrix of the virtual camera are applied to calculate the screen projection size value corresponding to the last geometric primitive group, and determine whether the screen projection size value is less than a first preset threshold value. If so, terminate the traversal of each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size; otherwise, continue to traverse each geometric primitive group in the set of geometric primitive groups of the combined block to be rendered in descending order of primitive size, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combined block to be rendered and closest to the virtual camera.

7. A 3D model rendering optimization device, characterized in that: It includes a geometric unit generation module, a space tree construction module, a combination block generation module, a geometric primitive grouping module and a primitive group rendering module which are sequentially connected in communication; The geometric unit generation module is used to pre-process the component geometric data under the three-dimensional model to be rendered to generate all geometric units, wherein the geometric units include vertex data; The spatial tree construction module is used to construct a spatial tree in which only leaf nodes are assigned with the geometric units according to all the geometric units; The combined block generation module is used to generate a corresponding combined block to be rendered for each leaf node on the spatial tree according to all the geometric units assigned to the corresponding node, wherein the combined block to be rendered includes a vertex data set; The geometric primitive grouping module is used to generate a geometric primitive group set according to the vertex data set of the combined block to be rendered, and add the geometric primitive group set to the combined block to be rendered, wherein the geometric primitive group set includes at least one geometric primitive group arranged in descending order according to primitive size; The primitive group rendering module is used to traverse each geometric primitive group in the geometric primitive group set of the combination block to be rendered in descending order according to the primitive size when rendering the three-dimensional model to be rendered: according to the camera's nearest point and the maximum size of the geometric primitive group currently being traversed, apply the view matrix and projection matrix of the virtual camera to calculate the screen projection size value corresponding to the geometric primitive group currently being traversed, and determine whether the screen projection size value is greater than or equal to zero and whether it is less than a first preset threshold value. If so, terminate the rendering of the geometric primitive group currently being traversed and all geometric primitive groups that are not currently traversed, wherein the camera's nearest point refers to the point determined based on the vertex data set of the combination block to be rendered and closest to the virtual camera.

8. A computer device, characterized in that: It includes a memory, a processor and a transceiver which are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive messages, and the processor is used to read the computer program to execute the three-dimensional model rendering optimization method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed on the computer, the three-dimensional model rendering optimization method as described in any one of claims 1 to 6 is executed.

10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or the instruction is executed by a computer, the three-dimensional model rendering optimization method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Dynamic vertex compression method for BIM lightweight data processing

    CN120852545A

  • A dynamic vertex compression method for lightweight BIM data processing

    CN120852545B