A three-dimensional model frame generation method for large-scale scene optimization

CN123015849APending Publication Date: 2026-10-30四川易方智慧科技有限公司 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611441666.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-17
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0007]本发明的目的在于提供一种大规模场景优化的三维模型分帧生成方法,解决的问题:在保证生成过程中界面与渲染稳定的同时,按材质分组批量合并,以显著降低绘制调用,通过分批阈值与32位索引避免网格溢出与内存峰值,从而解决大规模场景构建的性能瓶颈;具体方案如下:

Benefits of technology

本发明的生成过程更平滑,分帧策略显著降低卡顿,提升了编辑器与运行时的交互体验。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123015849A_ABST
    Figure CN123015849A_ABST
Patent Text Reader

Abstract

The application belongs to the field of three-dimensional model generation, and relates to a three-dimensional model frame generation method for large-scale scene optimization, which comprises the following steps: reading vector geometry data and attribute data, and obtaining a feature set by analysis; converting the coordinates of each feature in the feature set to a three-dimensional engine coordinate system; programmatically modeling the features in the engine coordinate system according to frames, generating temporary mesh objects carrying materials for each feature, and adding the temporary mesh objects to a merging queue; when the number of temporary mesh objects in the merging queue reaches a batch threshold, triggering batch merging; after all features are processed, performing batch merging on the temporary mesh objects in the merging queue again, and outputting the merging result objects as scene assets supporting block management; and simultaneously ensuring the stability of the interface and rendering during the generation process, significantly reducing the drawing call, and breaking through the performance bottleneck of large-scale scene construction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of 3D model generation, and specifically discloses a method for generating 3D models in frames based on large-scale scene optimization. Background Technology

[0002] In digital twin cities, city-level 3D editors, and real-time rendering engines, it is often necessary to generate 3D models of buildings, roads, and water bodies in batches based on vector data. City-level vector data typically includes building outlines, multi-component surfaces, road centerlines or surfaces, and water body surfaces. Converting these into assets usable by the real-time engine requires processing such as coordinate transformation, surface filling and triangulation, sidewall extrusion, texture mapping, and material assignment, while ensuring interactivity and high frame rates in the final scene.

[0003] However, when dealing with large datasets, batch generation of 3D models based on vector data often encounters performance bottlenecks due to the large data volume, long generation time, and low frame rate. These bottlenecks are mainly manifested in the following ways: stuttering during the generation phase, where generating tens of thousands of buildings at once can block the main thread, causing the editor to become unresponsive or experience severe frame drops during runtime; excessive drawing calls during the rendering phase, with a large number of discrete meshes and multi-material objects resulting in huge rendering submission overhead; unreasonable merging strategies, where direct full merging can lead to excessively high memory peaks, mesh index overflow, or material loss; and difficulty in achieving both visual effects and performance, where reducing geometry or texture quality for performance will cause visual loss, while maintaining high quality is difficult to meet real-time requirements.

[0004] Existing implementation methods mainly include the following categories: one-time full generation, which generates meshes and instantiates objects for all elements in a single frame, which is fast but can cause lag or even crashes; frame-by-frame generation without merging, which avoids lag by generating frames in a coroutine manner, but still results in a large number of small mesh objects, leading to high drawing calls; coarse-grained full merging, which merges all meshes into one large mesh, resulting in low drawing calls but is not conducive to management by material or region, and is prone to triggering index overflow and memory spike issues; and offline baking, which exports the generated results offline as model files and then imports them, which has high running efficiency but cannot quickly respond to data changes and has a poor editing experience.

[0005] The aforementioned existing technologies lack a combined strategy of frame generation, batch merging, and material grouping, making it difficult to simultaneously optimize the generation experience and running frame rate; when merging meshes, the preservation of multiple materials and sub-meshes is not considered, resulting in material misalignment or loss; 32-bit indexing is not enabled, causing meshes to become unusable when the number of vertices exceeds 65535; the merging granularity is uncontrollable, making it difficult to balance memory, culling, collision, and editing requirements.

[0006] In view of this, the present invention provides a method for generating 3D models in large-scale scenes by frame segmentation. By combining frame segmentation generation with a batch mesh merging strategy, it solves the performance bottleneck of large-scale urban scene construction while ensuring visual effects, and provides a reusable and scalable engineering implementation path for building distribution algorithms, procedural modeling and PBR mapping. Summary of the Invention

[0007] The purpose of this invention is to provide a frame-by-frame generation method for large-scale scene optimization, addressing the following problems: while ensuring interface and rendering stability during the generation process, batch merging is performed by material grouping to significantly reduce drawing calls; batch thresholding and 32-bit indexing are used to avoid mesh overflow and memory spikes, thereby solving the performance bottleneck of large-scale scene construction; the specific solution is as follows: A method for generating frame-by-frame 3D models with large-scale scene optimization includes: Step 1: Read the vector geometric data and attribute data, and parse them to obtain the feature set; Step 2: Transform the coordinates of each element in the element set to the 3D engine coordinate system to obtain the elements in the engine coordinate system; Step 3: Perform procedural modeling of features in the engine coordinate system frame by frame, generate a temporary mesh object with material for each feature and add it to the merge queue; when the cumulative number of features processed in this frame reaches the preset frame threshold, pause the processing of this frame and continue processing in the next frame until all features have been processed. Step 4: When the number of temporary mesh objects in the merge queue reaches the batch threshold, batch merging is triggered; the batch merging includes: in the first stage, the temporary mesh objects in the merge queue are grouped by material, and the meshes in each material group are merged to obtain the intermediate mesh corresponding to that material; in the second stage, each intermediate mesh is merged as an independent sub-mesh into the final mesh, retaining the multi-material structure, to obtain the merged result object, and the merge queue is cleared. Step 5: After all elements have been processed, perform the batch merging again on the temporary grid objects in the merging queue that are less than the batch threshold, and output each merging result object as a scene asset that supports block management.

[0008] Furthermore, the vector geometric data is SHP geometric data; The attribute data is a DBF attribute table; The set of elements includes multiple types of elements, including buildings, roads and water bodies, and the elements are sent to the corresponding generators according to their types.

[0009] Furthermore, the framing threshold includes a threshold for the number of elements per frame and a time budget per frame; When processing by frame, processing of the current frame is paused when the cumulative number of elements processed in the current frame reaches the threshold for the number of elements per frame or when the cumulative time consumed in the current frame reaches the time budget for the current frame.

[0010] Furthermore, the procedural modeling includes: The outline of the feature is filled and triangulated, and then stretched along the height direction to generate a wall, resulting in a temporary mesh object that includes multiple sub-mesh of the wall; the wall includes a lower wall, an upper wall, a roof, and a parapet wall.

[0011] Furthermore, step 3 also includes generating a material carrying the temporary mesh object, including: Based on physically based rendering, the corresponding material set is selected according to the building height, and the corresponding material is bound to each sub-mesh of the temporary mesh object.

[0012] Furthermore, step 3 also includes grouping the temporary mesh objects in the merging queue according to their carrying material, including: The sub-mesh of each temporary mesh object is mapped to a merge instance according to its bound material, and a list of merge instances corresponding to each material is collected. The list of merge instances is then used as the input for the first stage of merging.

[0013] Furthermore, the merger in the first phase is as follows: Flatten and merge the meshes within the material group to obtain the intermediate mesh containing only a single sub-mesh; The second phase of the merger is as follows: Each intermediate mesh is merged as an independent sub-mesh without flattening, so that the number of sub-meshes in the final mesh is equal to the actual number of materials in the batch, and the material array is assigned to the final mesh in the order of the sub-meshes.

[0014] Furthermore, step 4 also includes: Before performing the batch merging, the grid's index format is set to a 32-bit index; After merging, verify the number of vertices and the integrity of triangles in the final mesh.

[0015] Furthermore, the obtained merged result object includes: Attach a renderer and a collider to the merged result object and mark it as a static object; Clearing the merge queue includes: Destroy or recycle the temporary mesh objects in this batch.

[0016] Furthermore, the scene asset output supporting block management includes: The merged result objects are organized into blocks according to their respective batches and output as static scene assets. Each block can be independently culled, collided, and edited.

[0017] The present invention has the following advantages and beneficial effects: The generation process of this invention is smoother, the frame-segmentation strategy significantly reduces stuttering, and improves the interactive experience between the editor and the runtime.

[0018] This invention offers higher performance by grouping and merging materials to reduce draw calls, while retaining multi-material sub-mesh, thus balancing performance and visual effects.

[0019] The present invention is more stable, and the batch merging and 32-bit index can avoid grid overflow and memory peak risks, making it more suitable for city-level data scales.

[0020] The present invention has better engineering maintainability, and the merged results are output in blocks for easy management, elimination and subsequent editing. It can be extended in collaboration with building distribution algorithms, procedural modeling and physical rendering-based texture systems. Attached Figure Description

[0021] Figure 1 An exemplary flowchart of a large-scale scene optimization 3D model frame generation method provided by the present invention; Figure 2 The image shows a city scene rendering obtained after being generated and batch merged using the 3D model frame generation method provided by this invention. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0023] This invention provides a method for generating 3D models in large-scale scene optimization by frame segmentation, which includes, in sequence, reading vector data (SHP / DBF), coordinate transformation, feature classification, generating meshes and temporary objects in frames, material mapping and sub-mesh assignment, collecting and merging instances by material grouping, batch merging (32-bit index), generating merged result objects and colliders, and outputting static scene assets. Specifically, the process of generating 3D models in large-scale scene optimization includes a data preparation and scheduling process, a procedural modeling and queuing process, a batch merging process, and a scene object and output process. The data preparation and scheduling process outputs data to the procedural modeling and queuing process. When the number of queues is greater than N, the procedural modeling and queuing process transmits data to the batch merging process; when the number of queues is less than or equal to N, it transmits data back to the data preparation and scheduling process. The batch merging process transmits data to the scene object and output process. The data preparation and scheduling process includes input data, feature parsing and classification, coordinate transformation, and frame generation scheduling. Input data includes SHP and DBF. Feature parsing and classification includes buildings, roads, and water bodies, etc. Coordinate transformation converts coordinates to Unity coordinates. Frame generation scheduling includes the number of K elements and a time budget of T. The procedural modeling and queuing process includes procedural modeling, material mapping and PBR, collection of queues to be merged, and queue size determination. Procedural modeling includes triangulation, stretching, and submesh generation. Material mapping and PBR includes multi-material submesh generation. When the number of queues is less than or equal to N, data is returned for frame generation scheduling. The batch merging process includes grouping by material, merging within materials, and secondary merging of the final mesh. Grouping by material includes Combine Instance; when the number of queues is greater than N, data is received from the procedural modeling and queuing process. Intra-material merging includes large material meshes. Secondary merging of the final mesh includes UInt32 indices. The scene object and output process includes generating merged result objects and outputting large-scale scenes. Generating merged result objects includes Renderer, Collider, and Static. Outputting large-scale scenes includes low DrawCall and tileable management. Figure 1 As shown, it includes the following steps 1 to 5.

[0024] Step 1: Read the vector geometric data and attribute data, parse them to obtain the feature set and classify them by type.

[0025] The process involves reading vector geometric data and attribute data, parsing them to obtain a feature set, classifying the features by type, and extracting the outline point sequence and height from the building features. Vector geometric data refers to data describing the spatial shape and location of features using geometric primitives such as points, lines, and polygons. Attribute data refers to tabular data that corresponds one-to-one with each feature in the vector geometric data, recording its non-geometric characteristics such as height, type, and name. The feature set is the collection of all read features, which can be represented as: ; in, For a set of elements, , and These represent the 1st, 2nd, and nth features, respectively, where n is the total number of features. Architectural features are those whose geometry is a closed outline surface and whose attributes contain height information that can be used for stretching.

[0026] In some embodiments, the vector geometric data is SHP geometric data, and the attribute data is a DBF attribute table. SHP geometric data refers to geometric data stored in Shapefile format, which may contain point, line, and polygon geometry. The DBF attribute table is an attribute table that corresponds one-to-one with the SHP geometric data in record order and stores feature attributes in dBase table format. Feature types may include buildings, roads, and water bodies, etc., and features are sent to the corresponding generators according to their type. For example, the outline point sequence and height field are extracted from building polygon features and sent to the building generator, while features such as roads and water bodies are sent to the corresponding generators according to their type.

[0027] For architectural features, the height is extracted by dynamically matching the height field in the attribute data based on the column name. The height field refers to the field in the attribute data that records the building height. Its field name can be a preset default name (e.g., Height) or it can be dynamically matched based on the actual column name. When the height field is missing or fails to be parsed, a fallback value is assigned to the missing height. For example, a preset default floor height or default height value is assigned to ensure that subsequent stretching modeling is not interrupted.

[0028] Step 2: Transform the coordinates of each element to the 3D engine coordinate system to obtain the elements in the engine coordinate system.

[0029] The coordinates of each element in the element set are transformed from their original geographic or projected coordinates to the 3D engine coordinate system, resulting in elements in the engine coordinate system. The 3D engine coordinate system refers to the scene coordinate system used by the target real-time rendering engine. For example, the left-handed coordinate system used by the Unity engine. Coordinate transformation maps the geographic or projected coordinates of vector data to this scene coordinate system according to preset alignment rules, so that subsequent modeling, merging, and rendering can be performed in the engine.

[0030] Step 3: Perform procedural modeling on each element frame by frame, generate temporary mesh objects with materials, and add them to the merge queue.

[0031] Procedural modeling involves sequentially modeling each feature in the engine coordinate system frame by frame, generating a temporary mesh object with materials for each feature and adding it to a merge queue. Procedural modeling refers to the process of automatically generating a 3D mesh based on the geometry and attributes of the features according to preset rules. A temporary mesh object is an object with mesh and materials created for a single feature during the frame generation phase. The merge queue is a queue used to temporarily store temporary mesh objects to be merged.

[0032] In procedural modeling, the outline of a feature is triangulated and then extruded along its height to generate walls, resulting in a temporary mesh object containing multiple sub-mesh types of walls. The walls include side walls (lower and upper walls), roof, and parapet walls. Triangulation refers to the process of dividing the outline of a feature into several triangular facets to fill its interior. Extrusion refers to the process of extruded the planar outline along its height to generate solid geometry with walls. A sub-mesh is a subset of triangular facets within a mesh object, divided by material, that can be independently submitted for drawing. A parapet wall is a low wall extending above the roof surface around the perimeter of a building's roof.

[0033] Physically based rendering (PBR) materials are used to generate materials for temporary mesh objects. A corresponding material set is selected based on the building height, and each sub-mesh of the temporary mesh object is then bound to the corresponding material. Physically based rendering materials refer to materials that describe the surface optical properties using parameters such as albedo, metallicity, and roughness, based on a physically based lighting model. A material set refers to a pre-configured set of materials for a specific type of building (e.g., residential, high-rise), used to assign materials to sub-meshes such as lower walls, upper walls, roof, and parapet walls. For example, by selecting a material set for residential or high-rise buildings based on the building height, a building mesh containing multiple sub-meshes such as lower walls, upper walls, roof, and parapet walls is generated, and each is bound to its corresponding material. This multi-material sub-mesh structure serves as input for subsequent batch merging.

[0034] During frame-by-frame processing, when the cumulative number of elements processed in a frame reaches a preset frame threshold, processing for that frame is paused, and processing continues in the next frame until all elements have been processed. The frame threshold is used to determine whether processing should stop and yield the current frame; it includes at least one of a per-frame element quantity threshold K and a per-frame time budget T. The per-frame element quantity threshold K is the upper limit of the number of elements allowed to be processed in a single frame; the per-frame time budget T is the upper limit of the processing time allowed to be consumed in a single frame. Pausing processing for the current frame means returning control to the engine to complete rendering and interface response, and resuming processing in the next frame. In engineering, this is usually achieved through the yield operation of a coroutine. The condition for pausing processing for the current frame can be expressed as: ; Where count is the cumulative number of elements processed in this frame, and Δt is the cumulative time consumed in this frame.

[0035] For example, suppose the number of building elements in a city scene is |F|=12000, and the threshold number is K=500. Then, in the first frame, elements 1 to 500 are processed and a temporary mesh is generated, and then one frame is left unprocessed. In the second frame, elements 501 to 1000 are processed, and so on, until the processing is completed in about the 24th frame. If all 12000 elements are processed in a single frame without slicing, the main thread may be blocked for a long time, causing the editor to become unresponsive or to drop frames severely during runtime.

[0036] Alternatively, a time budget T can be used for slicing. For example, if T = 8ms, and time t0 is recorded at the start of a frame, if the cumulative time reaches or exceeds T after processing each feature, a frame is immediately relinquished regardless of how many features have been processed in that frame. This method is suitable for features with uneven geometric complexity; simple features can be processed in multiple frames, while complex multi-toroidal features are automatically relinquished in advance. In engineering, the two methods can be combined: each frame processes a maximum of K features, and the cumulative time does not exceed T; a frame is relinquished once either condition is met. During frame generation, a temporary mesh object and its corresponding mesh component (MeshFilter) are generated for each feature and enter the subsequent merging queue.

[0037] Step 4: When the batching threshold is reached, trigger the two-stage batch merging to retain the multi-material structure.

[0038] A batch merge is triggered when the number of temporary mesh objects in the merge queue reaches the batch threshold N. The batch threshold N is the threshold number of temporary mesh objects in the merge queue required to trigger a batch merge (e.g., N=1000). A batch merge refers to a two-stage merge performed only on the temporary mesh objects of the current batch, rather than a full merge of all already produced merge result objects.

[0039] The first stage groups temporary mesh objects in the merge queue by material, and merges the meshes within each material group to obtain the intermediate mesh corresponding to that material. A material group refers to a group consisting of temporary mesh objects bound to the same material. Grouping by material and collecting the merge instance list corresponding to each material can be represented as: ; in, To merge the list of instances, For object The corresponding merged instance, For objects, For the collection of mesh objects to be merged, A collection of materials, representing objects. The bound materials, where m is the material identifier and M is the set of materials appearing in the current batch, map the sub-mesh of each temporary mesh object to merge instances according to their bound materials, collect a list of merge instances corresponding to each material, and use this list of merge instances as input for the first stage of merging. A merge instance describes a sub-mesh to be merged and its transformations. The list of merge instances refers to the list of merge instances gathered within the same material group.

[0040] The first stage involves flattening and merging each material group to obtain the intermediate mesh corresponding to the material: ; in, The middle grid is defined by Merge(), which is the grid merging operator. This is a flattened merge. Flattened merge refers to a merge method that incorporates all triangular faces involved in the merge into a single sub-mesh (mergeSubMeshes=true). An intermediate mesh refers to the large material mesh containing only a single sub-mesh obtained after flattening and merging a material group. For example, all roofs are merged into Mesh_A, all walls into Mesh_B, and all glass into Mesh_C, thus compressing what would have been thousands of independent draws within that material group into a single operation.

[0041] The second stage merges each intermediate mesh as an independent sub-mesh into a final mesh, preserving the multi-material structure: ; in, For the final mesh, This is a non-flattened merge. Non-flattened merging refers to a merging method where each participating mesh is retained as an independent sub-mesh and not merged into the same sub-mesh (mergeSubMeshes=false). The final mesh is the main mesh obtained by compositing each intermediate mesh as an independent sub-mesh using non-flattened merging. A multi-material structure refers to a final mesh containing multiple sub-meshes corresponding to different materials, with rendering commands submitted separately for each sub-mesh. The final mesh's sub-mesh count is equal to the actual number of materials used in the batch, and material arrays are assigned to the final mesh in sub-mesh order. ; in, For material arrays, To take the absolute value.

[0042] The material array refers to an array that assigns the material to each sub-mesh in the final mesh according to the sub-mesh order, with the i-th item corresponding to the i-th sub-mesh. Thus, submesh0, submesh1, and submesh2 correspond to materials A, B, and C respectively. This achieves batch merging at the geometric level to reduce drawing calls, while preserving the binding relationships of multiple materials through the sub-mesh channels, achieving the effect of merging geometric submissions without merging material channels. If a flattening merge is directly performed on all meshes, all triangles are merged into a single sub-mesh, which can only be bound to one material, leading to color mixing or loss of materials such as roofs, walls, and glass. The two-stage merging of this invention avoids this problem.

[0043] In some embodiments, the structure of grouping and merging by material includes an input set of mesh objects, a material-grouped collection (Combine instance), and a two-stage merge output (retaining sub-meshes). The input set of mesh objects includes Obj_1 MatA, Obj_4 MatA, Obj_7 MatA, Obj_2 MatB, Obj_5 MatB, Obj_8 MatB, Obj_3 MatC, Obj_6 MatC, and Obj_9 MatC. The material-grouped collection includes material group A, material group B, and material group C. Material group A, material group B, and material group C each contain a list of Combine instances. Material group A receives data from Obj_1 MatA, Obj_4 MatA, and Obj_7 MatA. Material group B receives data from Obj_2 MatB, Obj_5 MatB, and Obj_8 MatB. Material group C receives data from Obj_3 MatC, Obj_6 MatC, and Obj_9 MatC. The two-stage merge output includes a large material mesh (Mesh_A), a large material mesh (Mesh_B), a large material mesh (Mesh_C), and a Combined Master sub-mesh. Large material meshes (Mesh_A, Mesh_B, and Mesh_C) all have `mergeSubMeshes=true`, receiving data from material groups A, B, and C respectively, and outputting the generated data to the Combined Master sub-mesh. The Combined Master sub-mesh outputs a batching threshold. The Combined Master sub-mesh includes A, B, and C (IndexFormat=UInt32). Batching threshold processing triggers a merge when the queue size exceeds N, outputting Combined_0, Combined_1, and Combined_2, etc. Materials A / B / C are merged into intermediate meshes, then merged again into a final mesh containing three sub-meshes; batch merging is triggered by the threshold N.

[0044] In some embodiments, before performing batch merging, the mesh index format is set to a 32-bit index to support meshes with more vertices than the 16-bit index limit; and after merging, the number of vertices and triangle integrity of the final mesh are verified. The 16-bit index limit refers to the upper limit of vertex indices when using 16-bit unsigned integers (UInt16), approximately 65535. The 32-bit index refers to the format of representing vertex indices using 32-bit unsigned integers (UInt32), which can support far more than 65535 vertices.

[0045] For example, suppose a batch of buildings to be merged, after being grouped by material, has approximately 48,000 vertices in the wall group and approximately 32,000 vertices in the roof group, totaling approximately 80,000 vertices. If a 16-bit index is still used, index overflow or engine refusal to build will occur because 80,000 > 65,535, resulting in broken faces, blank meshes, and other problems. Therefore, before the first or second stage of merging, the mesh index format is set to a 32-bit index, which can support a number of vertices far exceeding 65,535, and can be represented as: ; After merging, the number of vertices and the integrity of triangles are verified, then the results are attached to the merged object and assigned the corresponding material array. Thus, the batch threshold N controls the scale of a single batch merge and the peak memory usage, while the 32-bit index prevents index overflow caused by vertex overload; together, they provide a double guarantee for resource safety.

[0046] The triggering of batch merging and queue clearing can be represented as: ; Where Q is the merge queue, and CombineByMaterial(Q) represents the two-stage merge process described above. It is an empty set (representing an empty queue). To merge queues The clear assignment operation, Batch number The update operation increments by 1. Grouping and merging are performed on the actual material subset M_Q that appears in queue Q; each time it is triggered, only the temporary mesh of the current batch is merged in two stages to obtain a final mesh containing multiple material sub-meshes, which is then attached to the newly created merged result object, and then the queue is cleared to receive the next batch.

[0047] In some embodiments, obtaining the merged result object includes: attaching a renderer and a collider to the merged result object and marking it as a static object; clearing the merge queue includes destroying or reclaiming temporary mesh objects for the current batch. A renderer is a component responsible for submitting the drawing based on the final mesh and material array. A collider is a component that provides collision detection geometry for the merged result object. A static object is an object marked as having geometry that does not change during runtime, thus allowing it to participate in static optimizations such as batch processing and occlusion culling.

[0048] Step 5: After all elements have been processed, perform batch merging again on the temporary grid objects in the merging queue that are less than the batch threshold, and output each merged result object as a scene asset that supports block management.

[0049] After all elements have been processed, perform the batch merging again on any remaining temporary mesh objects (less than N) in the merging queue to avoid omissions; and output each merged result object as a scene asset supporting block management. Scene assets refer to scene objects or resources that can be loaded and used by the real-time rendering engine. Block management refers to organizing the merged results into batches of blocks, allowing each block to be independently culled, collide-detected, and edited. The batch output sequence can be represented as: ; in, , and These are batch numbers 0, 1, and... The merged result object obtained by merging in batches.

[0050] For example, taking N=1000 for 12,000 buildings will sequentially output approximately 12 merged result objects (blocky large meshes). The scene is neither composed of 12,000 discrete small objects, nor is it a process of merging the results from each batch into a single city mesh. This reduces rendering calls while controlling memory spikes and facilitates partitioned management, culling, and subsequent editing. Furthermore, each merged result object is organized into blocks according to its batch and output as static scene assets. Each block can be independently culled, collision detected, and edited, ultimately resulting in a large-scale scene with low rendering calls and manageable blocks.

[0051] Example 1: (1) During frame generation, each feature generates a temporary object with MeshFilter / MeshRenderer and enqueues it into Q; (2) Merging is triggered when |Q|≥N (e.g., N=1000); (3) Group the current batch of small meshes by material, first merge them within the material to obtain several intermediate material large meshes, and then merge them into the final large mesh Mesh_Batch of this batch in the form of sub-mesh, and enable 32-bit index; (4) Create a new merge root object (such as MergedBatch_k), attach Mesh_Batch and the actual material arrays that appear in this batch, and add collision bodies as needed; (5) Destroy or recycle this batch of temporary small objects and clear Q; (6) Continue to receive subsequent elements, and output the next merged root object every time N is full; when the queue has less than N remaining, merge again in the final stage to avoid omissions. For example, if N=1000 for 12000 buildings, about 12 merged root objects (block-shaped large grids) will be output in sequence. The scene is neither 12000 discrete small objects, nor is the result of each batch merged into a single grid for the whole city. This reduces DrawCall while controlling memory peaks and facilitates partition management, culling and subsequent editing.

[0052] Example 2: To make the objectives and technical solutions of this invention clearer, the following description, in conjunction with a city model generator based on the Unity engine, will further illustrate these points.

[0053] Read SHP / DBF files and generate building meshes. After the user selects a .shp file, automatically match a .dbf file with the same name, read the building outline and height fields (the default field name is Height, but dynamic matching by column name is supported); perform face filling triangulation on each building outline and stretch it along the Y-axis to generate wall and roof sub-meshes, assign physically based rendering materials according to rules, and provide fallback values ​​for missing heights.

[0054] Frame-by-frame generation. Set a threshold K for the number of elements processed per frame in the generation coroutine (e.g., K=500); when the cumulative number of processed elements countTemp exceeds K, reset the count to zero and yield one frame, returning control to the engine rendering and interface response, thereby avoiding long-term blocking of the main thread caused by generating tens of thousands of buildings at once.

[0055] Merging is done in batches by material. During frame generation, the mesh components of each temporary mesh object enter the merging queue. When the queue size exceeds a threshold N (e.g., N=1000), a two-stage merging is immediately performed on the current batch of temporary meshes. First, the sub-meshes of each temporary object are collected into a merge instance list by material. In the first stage, a flattening merge (mergeSubMeshes=true) is performed on the same material group to obtain intermediate meshes. In the second stage, each intermediate mesh is merged again as an independent sub-mesh (mergeSubMeshes=false) to obtain the final mesh, and the material array is assigned according to the sub-mesh order. The index format is set to UInt32 in both merges. Then, a new merge result object (named Combined_Sequence Number) is created, the final mesh, material array, and collider are attached and marked as a static object, the queue is cleared and the system continues to receive subsequent objects. After all features are processed, a final merging is performed on the remaining queues (less than N).

[0056] Effects and Performance. Post-generation rendering calls are significantly reduced, frame rate is stable, and material partitions such as rooftops and walls are preserved without loss, meeting the real-time rendering needs of large-scale urban scenes. The generated and batch-merged urban scene effects are as follows: Figure 2 As shown.

[0057] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for generating frame-by-frame 3D models for large-scale scene optimization, characterized in that, Includes the following steps: Step 1: Read the vector geometric data and attribute data, and parse them to obtain the feature set; Step 2: Transform the coordinates of each element in the element set to the 3D engine coordinate system to obtain the elements in the engine coordinate system; Step 3: Perform procedural modeling of features in the engine coordinate system frame by frame, generate a temporary mesh object with material for each feature and add it to the merge queue; when the cumulative number of features processed in this frame reaches the preset frame threshold, pause the processing of this frame and continue processing in the next frame until all features have been processed. Step 4: When the number of temporary mesh objects in the merge queue reaches the batch threshold, batch merging is triggered; the batch merging includes: in the first stage, the temporary mesh objects in the merge queue are grouped by material, and the meshes in each material group are merged to obtain the intermediate mesh corresponding to that material; in the second stage, each intermediate mesh is merged as an independent sub-mesh into the final mesh, retaining the multi-material structure, to obtain the merged result object, and the merge queue is cleared. Step 5: After all elements have been processed, perform the batch merging again on the temporary grid objects in the merging queue that are less than the batch threshold, and output each merging result object as a scene asset that supports block management.

2. The method for generating frames of a 3D model for large-scale scene optimization according to claim 1, characterized in that, The vector geometric data is SHP geometric data; The attribute data is a DBF attribute table; The set of elements includes multiple types of elements, including buildings, roads and water bodies, and the elements are sent to the corresponding generators according to their types.

3. The method for generating frames of a 3D model for large-scale scene optimization according to claim 1, characterized in that, The frame threshold includes the threshold for the number of elements per frame and the time budget per frame; When processing by frame, processing of the current frame is paused when the cumulative number of elements processed in the current frame reaches the threshold for the number of elements per frame or when the cumulative time consumed in the current frame reaches the time budget for the current frame.

4. The method for generating frames of a 3D model for large-scale scene optimization according to claim 1, characterized in that, The procedural modeling includes: The outline of the feature is filled and triangulated, and then stretched along the height direction to generate a wall, resulting in a temporary mesh object that includes multiple sub-mesh of the wall; the wall includes a lower wall, an upper wall, a roof, and a parapet wall.

5. The method for generating frames of a 3D model for large-scale scene optimization according to claim 4, characterized in that, Step 3 further includes generating a material carrying the temporary mesh object, including: Based on physically based rendering, the corresponding material set is selected according to the building height, and the corresponding material is bound to each sub-mesh of the temporary mesh object.

6. The method for generating frames of a 3D model for large-scale scene optimization according to claim 1, characterized in that, Step 3 further includes grouping the temporary mesh objects in the merging queue according to their carrying material, including: The sub-mesh of each temporary mesh object is mapped to a merge instance according to its bound material, and a list of merge instances corresponding to each material is collected. The list of merge instances is then used as the input for the first stage of merging.

7. The method for generating frames of a 3D model for large-scale scene optimization according to claim 1, characterized in that, The first phase of the merger is as follows: Flatten and merge the meshes within the material group to obtain the intermediate mesh containing only a single sub-mesh; The second phase of the merger is as follows: Each intermediate mesh is merged as an independent sub-mesh without flattening, so that the number of sub-meshes in the final mesh is equal to the actual number of materials in the batch, and the material array is assigned to the final mesh in the order of the sub-meshes.

8. The method for generating frames of a 3D model for large-scale scene optimization according to claim 1, characterized in that, Step 4 also includes: Before performing the batch merging, the grid's index format is set to a 32-bit index; After merging, verify the number of vertices and the integrity of triangles in the final mesh.

9. The method for generating frames of a 3D model for large-scale scene optimization according to claim 1, characterized in that, The merged result object includes: Attach a renderer and a collider to the merged result object and mark it as a static object; Clearing the merge queue includes: Destroy or recycle the temporary mesh objects in this batch.

10. The method for generating frame-by-frame 3D models for large-scale scene optimization according to claim 1, characterized in that, The scenario asset output supporting block management includes: The merged result objects are organized into blocks according to their respective batches and output as static scene assets. Each block can be independently culled, collided, and edited.