CN-121746510-B - Dynamic loading method for 3D model by using Unity engine
Abstract
The application relates to the technical field of model loading, in particular to a 3D model dynamic loading method by using a Unity engine, which comprises the steps of obtaining OSGB files of a three-dimensional model obtained by reconstructing image data, importing the OSGB files into the Unity engine after converting formats, and constructing a tree index structure by using file naming rules, wherein each node is associated with a corresponding grid model and a map image; and calculating the visual field desalination degree, visual richness, visual saliency, motion coefficient and rendering evaluation value of each node, optimizing a node evaluation function of an LOD algorithm, dynamically scheduling and loading a grid model and a map image of a corresponding detail level according to the evaluation result of the node for rendering. The application improves the realism and immersion of the scene picture while ensuring high-performance rendering.
Inventors
- CHEN FENG
- DENG KAI
- WANG XIN
Assignees
- 杭州墨启时空科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260224
Claims (9)
- 1. A method for dynamically loading a 3D model by using a Unity engine is characterized by comprising the following steps: Obtaining OSGB files of a three-dimensional model obtained by reconstructing image data, importing the files into a Unity engine after converting the formats, and constructing a tree index structure by utilizing file naming rules, wherein each node is associated with a corresponding grid model and a map image; Aiming at each node in the view range of the main camera at each moment, analyzing the space distance relation between the grid model of each node and the main camera and the occupation ratio situation that the view of the grid model is not blocked, and calculating the view desalination degree of each node; Evaluating the quantity and shape differences of the map images of the nodes corresponding to different connected domains and the complex condition of color information contained in the map images, calculating the visual richness of the nodes, and combining the visual field desalination degree to obtain the visual saliency of the nodes; Calculating the motion coefficient of each node according to the displacement change condition of pixel points in the map image of the same node at adjacent moments and the number of the pixel points with displacement, calculating the rendering evaluation value of each node by combining the dynamic change condition and visual saliency of a main camera at adjacent moments, optimizing the node evaluation function of an LOD algorithm, dynamically scheduling and loading a grid model and the map image of a corresponding detail level according to the evaluation result of the node in the view range of the main camera for rendering; First, the The time is located in the field of view of the main camera Rendering evaluation value of individual node The calculation formula of (2) is as follows: , wherein, Is the first The time is located in the field of view of the main camera The rendering evaluation value of the individual node, Is the first The time is located in the field of view of the main camera The visual saliency of the individual nodes is, Is the first The time is located in the field of view of the main camera The motion coefficients of the individual nodes are used, Is a preset weight factor, and the weight factor is a preset weight factor, Is the first The time is located in the field of view of the main camera The distance of the individual nodes to the main camera, Is the first The time is located in the field of view of the main camera Distance of the individual nodes to the main camera.
- 2. The method for dynamically loading a 3D model using a Unity engine according to claim 1, wherein the tree index structure is a quadtree structure.
- 3. The method for dynamically loading a 3D model by using a Unity engine according to claim 1, wherein the calculating the field of view desalination degree of each node comprises: calculating the distance between the center position of each surface in the bounding box and the main camera, and selecting the surface corresponding to the minimum distance as a visual field surface; dividing the view surface into a plurality of subareas, carrying out line-of-sight shielding detection on each subarea, and counting the ratio of the number of subareas without line-of-sight shielding to the number of all subareas corresponding to the view surface as a non-shielding duty ratio; Calculating the distance between the center position of the bounding box of each node and the main camera; The visual field desalination degree and the distance are in positive correlation and in negative correlation with the visual field duty ratio.
- 4. The method for dynamically loading the 3D model by using the Unity engine according to claim 1, wherein the calculating the visual richness of each node comprises: extracting all connected domains in the gray level image corresponding to the map image, and calculating Hu moment values of all connected domains; calculating the discrete degree of Hu moment values of all connected domains in the gray image; calculating the image entropy of the pixel values of all pixel points under each color channel in the mapping image corresponding to each node; counting the number of all connected domains in the gray image; The visual richness is the result of fusion of the number, the discrete degree and the average image entropy.
- 5. The method for dynamically loading the 3D model by using the Unity engine according to claim 4, wherein the specific process of fusion is to take the product of the number, the degree of dispersion and the average image entropy as the visual richness.
- 6. The method for dynamically loading a 3D model using a Unity engine according to claim 1, wherein the visual saliency is a ratio of the visual richness to the visual field desalination.
- 7. The method for dynamically loading the 3D model by using the Unity engine according to claim 1, wherein the calculating the motion coefficients of each node comprises: inputting the map images corresponding to the same node at each moment and the previous moment into an optical flow algorithm, obtaining displacement vectors of all pixel points, and calculating the modular length of the displacement vectors; Obtaining the dividing threshold value of the modular length of all pixel points in the map image corresponding to each node in the field of view of the main camera at each moment, and marking the pixel points with the modular length being more than or equal to the dividing threshold value as moving pixel points; Counting the number proportion of the moving pixel points in the map image corresponding to each node in the field of view of the main camera at each moment; And the motion coefficient is a normalized result of the product of the average value of the modular lengths of all the motion pixel points in the map image and the quantity ratio.
- 8. The method for dynamically loading a 3D model by using a Unity engine according to claim 1, wherein the optimized node evaluation function has the formula: , wherein, As a result of the evaluation of the node, Is the distance from the center of the bounding box of the node to the main camera, For the side length of the node, And rendering evaluation values for the nodes.
- 9. The method for dynamically loading a 3D model by using a Unity engine according to claim 1, wherein the step of dynamically scheduling and loading the grid model and the map image of the corresponding detail level for rendering comprises the steps of carrying out subdivision operation on the detail level of each node to load and render the descendant node if the evaluation result of each node in the view range of the main camera at each moment is less than 1, and maintaining the detail level of the node and rendering if the evaluation result is greater than or equal to 1.
Description
Dynamic loading method for 3D model by using Unity engine Technical Field The application relates to the technical field of model loading, in particular to a 3D model dynamic loading method by using a Unity engine. Background With the rapid development of the fields of smart cities, digital twinning, entertainment games and the like, a large-scale and high-precision three-dimensional model becomes a core element for constructing an immersive virtual environment. However, the Unity engine needs extremely large computer graphic calculation force in loading and rendering the three-dimensional model, so that the real-time smooth loading of the large-scale live-action model is realized, and the multi-level detail technology can dynamically adjust the rendering precision, thereby reducing the load of real-time rendering. The traditional multi-level detail technology generally only depends on a static geometrical relation of a space distance between a node and a main camera to adjust a detail level, and can not effectively distinguish inherent visual importance differences in a scene, so that excessive rendering precision is distributed to an object with a very close distance but simple visual texture, and calculation force waste is caused, and an object with a far distance but complex structure and rich details appears fuzzy due to insufficient precision. Disclosure of Invention In order to solve the technical problems, a method for dynamically loading a 3D model by using a Unity engine is provided to solve the existing problems. The application provides a method for dynamically loading a 3D model by using a Unity engine, which comprises the following steps: Obtaining OSGB files of a three-dimensional model obtained by reconstructing image data, importing the files into a Unity engine after converting the formats, and constructing a tree index structure by utilizing file naming rules, wherein each node is associated with a corresponding grid model and a map image; Aiming at each node in the view range of the main camera at each moment, analyzing the space distance relation between the grid model of each node and the main camera and the occupation ratio situation that the view of the grid model is not blocked, and calculating the view desalination degree of each node; Evaluating the quantity and shape differences of the map images of the nodes corresponding to different connected domains and the complex condition of color information contained in the map images, calculating the visual richness of the nodes, and combining the visual field desalination degree to obtain the visual saliency of the nodes; Calculating the motion coefficient of each node according to the displacement change condition of the pixel points in the map image of the same node at adjacent moments and the number of the pixel points with displacement, calculating the rendering evaluation value of each node by combining the dynamic change condition and the visual saliency of the main camera at adjacent moments, optimizing the node evaluation function of an LOD algorithm, and dynamically scheduling and loading a grid model and the map image of the corresponding detail level according to the evaluation result of the nodes in the view range of the main camera for rendering. Preferably, the tree index structure is a quadtree structure. Preferably, the calculating the field of view desalination degree of each node includes: calculating the distance between the center position of each surface in the bounding box and the main camera, and selecting the surface corresponding to the minimum distance as a visual field surface; dividing the view surface into a plurality of subareas, carrying out line-of-sight shielding detection on each subarea, and counting the ratio of the number of subareas without line-of-sight shielding to the number of all subareas corresponding to the view surface as a non-shielding duty ratio; Calculating the distance between the center position of the bounding box of each node and the main camera; The visual field desalination degree and the distance are in positive correlation and in negative correlation with the visual field duty ratio. Preferably, the calculating the visual richness of each node includes: extracting all connected domains in the gray level image corresponding to the map image, and calculating Hu moment values of all connected domains; calculating the discrete degree of Hu moment values of all connected domains in the gray image; calculating the image entropy of the pixel values of all pixel points under each color channel in the mapping image corresponding to each node; counting the number of all connected domains in the gray image; The visual richness is the result of fusion of the number, the discrete degree and the average image entropy. Preferably, the specific process of fusion is to take the product of the number, the discrete degree and the average image entropy as the visual richness. Preferably, the visual