2D Bin Packing Method for Fragmented Textures Optimization of Detailed Building Model
-
摘要: 为了解决精细建筑物模型大量碎片化纹理造成模型加载时间长和实时渲染效率低的问题,提出一种精细建筑物碎片化纹理优化的二维装箱方法. 计算共用纹理并集区域,优化冗余纹理内容,并同时顾及超出常规坐标[0,1.0]范围的异常纹理;使用二维装箱算法对优化后的离散纹理进行封装,降低纹理数量;利用纹理映射和纹理集技术将优化后的纹理重映射到建筑物表面,然后对建筑群进行实验.研究结果表明:使用本文方法,纹理数据量减少了71.20%,纹理文件数量减少了99.37%,模型载入耗时减少了98.86%,图像处理器耗时减少了63.06%,并可有效避免因异常纹理坐标导致的纹理错误映射问题,同时也提高了数据格式的兼容性.Abstract: To solve the problem of long loading time and low real-time rendering efficiency caused by large amount of fragmented textures of the detailed building model, a 2D bin packing method for fragmented textures optimization of the detailed building model was presented. The union regions of shared textures were calculated, the redundant textures content were optimized, and the abnormal textures beyond the normal coordinates [0, 1.0] were taken into account at the same time. The 2D bin packing algorithm was employed to encapsulate the optimized textures to reduce the textures number. The texture mapping and texture atlas techniques were used to remap the optimized textures to the building surface, then, experiments were carried out on the building complex. The results show that the amount of textures data reduce by 71.20%, the number of textures files reduce by 99.37%, the time required for model loading reduce by 98.86%, the time consumption of central processing unit reduce by 63.06%, and the problem of textures mapping error caused by abnormal textures coordinates can be avoided effectively, at the same time the data format compatibility can be improved.
-
表 1 原始模型纹理数据统计结果
Table 1. Statistics results of original model textures data
模型名称 纹理文件个数百分比/% 1 KB 2 KB 3 KB 4 KB 模型 1 68.70 17.00 5.90 2.00 模型 2 47.00 11.60 4.50 5.20 模型 3 47.20 21.70 11.10 4.40 模型 4 44.80 35.00 9.40 8.30 模型 5 42.00 29.20 1.09 60.00 模型 6 44.90 26.30 7.70 4.10 模型 7 50.80 25.10 3.80 2.70 模型 8 39.60 24.70 6.10 4.80 表 2 纹理数据对比结果
Table 2. Textures data comparison
MB 模型名称 纹理数据量 原始模型 MaxRectsBinPack 本文方法 模型 1 2.17 1.71 1.43 模型 2 5.54 2.08 1.11 模型 3 1.29 1.25 1.24 模型 4 1.53 1.55 1.55 模型 5 5.24 3.96 3.73 模型 6 36.00 24.51 4.77 模型 7 1.74 0.75 0.54 模型 8 7.53 4.21 3.21 纹理数据量总和 61.04 40.02 17.58 表 3 载入与绘制效率对比
Table 3. Load and draw efficiency comparison
方法 纹理文件数量 载入耗
时/sGPU 耗
时/ms渲染帧
率/fps原始模型 4281 225.00 4.25 60.14 MaxRectsBinPack 125 9.85 2.28 59.98 本文方法 27 2.56 1.57 60.00 表 4 算法效率对比(耗时)
Table 4. Algorithm efficiency comparison (time)
s 模型
名称MaxRectsBinPack 本文方法 纹理
合并纹理重
映射纹理去
冗余纹理
合并纹理重
映射模型 1 24.98 0.62 2.98 17.32 0.82 模型 2 20.33 0.28 1.31 2.60 0.25 模型 3 4.12 0.41 1.21 4.00 0.28 模型 4 3.82 0.27 1.41 3.05 0.36 模型 5 162.14 1.36 9.24 111.33 2.16 模型 6 124.35 2.29 22.77 282.30 4.00 模型 7 6.77 0.30 0.91 5.98 0.29 模型 8 8.64 0.49 4.66 3.73 0.59 -
朱庆, 徐冠宇, 杜志强, 等. 倾斜摄影测量技术综述[EB/OL]. [2012-05-22]. http://www.paper.edu.cn/releasepaper/content/201205-355. 王伟,黄雯雯,镇姣. Pictometry倾斜摄影技术及其在3维城市建模中的应用[J]. 测绘与空间地理信息,2011,34(3): 181-183. doi: 10.3969/j.issn.1672-5867.2011.03.060WANG Wei, HUANG Wenwen, ZHEN Jiao. Pictometry oblique photography technique and its application in 3D city modeling[J]. Geomatics & Spatial Information Technology, 2011, 34(3): 181-183. doi: 10.3969/j.issn.1672-5867.2011.03.060 龚俊,朱庆,章汉武,等. 基于R树索引的三维场景细节层次自适应控制方法[J]. 测绘学报,2011,40(4): 531-534.GONG Jun, ZHU Qing, ZHANG Hanwu, et al. An adaptive control method of LODs for 3D scene based on R-tree index[J]. Acta Geodaetica et Cartographica Sinica, 2011, 40(4): 531-534. 周东波. 顾及粒度的三维城市模型数据高效组织方法[D]. 武汉: 武汉大学, 2010. 李媛,胡翰,谢金华,等. 局部区域表面一致性约束的三维模型纹理映射方法[J]. 武汉大学学报(信息科学版),2016,41(12): 1599-1604.LI Yuan, HU Han, XIE Jinhua, et al. An automatic texture mapping method using local surface consistency constraint[J]. Geomatics and Information Science of Wuhan University, 2016, 41(12): 1599-1604. DIRK F, FRANK S, KLAUS H. Flexible clipmaps for managing growing textures[C]//GRAPP-International Conference on Computer Graphics Theory and Applications. Algarve: GRAPP, 2011: 173-180. 王旭东,张福浩,张丽萍. 基于地形数据的瓦片金字塔构建与组织[J]. 测绘与空间地理信息,2012,6: 49-51. doi: 10.3969/j.issn.1672-5867.2012.06.014WANG Xudong, ZHANG Fuhao, ZHANG Liping. Construction and organization of tile-pyramid based on terrain data[J]. Geomatics & Spatial Information Technology, 2012, 6: 49-51. doi: 10.3969/j.issn.1672-5867.2012.06.014 ADRIAN T, ION C, DINU C. Block map implementation of difference expansion reversible watermarking[C]//ISSCS 2011-International Symposium on Signals, Circuits and Systems. Lasi: IEEE, 2011: 1-4. RAFAEL P, SERGIO A, FRANCISCO M B, et al. Composition of texture atlases for 3D mesh multi-texturing[C]//Proceedings of the Eurographics Italian Chapter Conference EG-IT 2010. Genova: Eurographics Italian Chapter Conference, 2010: 123-128. RAFAEL P, DANIEL B, FRANCISCO M B, et al. Seamless,static multi-texturing of 3D meshes[J]. Computer Graphics Forum, 2014, 34(1): 228-238. 江巨浪,黄忠,郑江云. 基于三角形包围盒的纹理地图集生成算法[J]. 吉林大学学报(工学版),2012,42(6): 1543-1547.JIANG Julang, HUANG Zhong, ZHENG Jiangyun. Algorithm for texture atlas generation based on triangular bounding box[J]. Journal of Jilin University (Engineering and Technology Edition), 2012, 42(6): 1543-1547. 杜志强,罗盼,朱晓玲,等. 基于超面的建筑物纹理优化处理方法[J]. 武汉大学学报(信息科学版),2014,39(12): 1401-1405.DU Zhiqiang, LUO Pan, ZHU Xiaoling, et al. Texture optimization methodology for 3D building based on super face[J]. Geomatics and Information Science of Wuhan University, 2014, 39(12): 1401-1405. 戴雪峰,熊江汉,龚健雅. 一种三维城市模型多纹理自动合并方法[J]. 武汉大学学报(信息科学版),2015,40(3): 347-352.DAI Xuefeng, XIONG Jianghan, GONG Jianya. A multi-texture automatic merging approach for the 3D city models[J]. Geomatics and Information Science of Wuhan University, 2015, 40(3): 347-352. LIMPER M, VINING N, SHEFFER A. Box cutter:atlas refinement for efficient packing via void elimination[J]. ACM Trans. Graph., 2018, 37(4): 153.1-153.13. SPALLA I. Texture atlas creation approaches within Maya: a comparative study[D]. West lafayette: Purdue University, 2017. ZHANG W, LI M, GUO B, et al. Rapid texture optimization of three-dimensional urban model based on oblique images[J]. Sensors, 2017, 17(911): 1-15. doi: 10.3390/s17040911 ODAKER T, WIEDEMANN M, ANTHES C, et al. Texture analysis and repacking for improved storage efficiency[C]//Proceedings of the 22nd ACM Conference on Virtual Reality Software and Technology. Munich: ACM, 2016: 361-362. KO M. A fast and high-quality texture atlasing algorithm[J]. Game Engine Gems, 2016: 3-5. 宋歌,杨红雨. 基于纹理集的大规模场景模型优化算法[J]. 计算机工程与设计,2011,32(9): 3119-3122.SONG Ge, YANG Hongyu. Optimization algorithm for large scale scene models based on texture atlas[J]. Computer Engineering and Design, 2011, 32(9): 3119-3122. JYLANKI J. A thousand ways to pack the bin-a practical approach to two-dimensional rectangle bin packing[EB/OL]. (2010-02-27)[2017-11-10]. http://clb.demon.fi/files/RectangleBinPack.pdf. NIKHIL B, ARINDAM K. Improved approximation algorithm for two-dimensional bin packing[C]// Proceedings of the 2014 annual ACM-SIAM Symposium on Discrete Algorithms. Portland: Society for Industrial and Applied Mathematics, 2014: 13-25. CHRISTOFOROS C, KRZYSZTOF F. A constructive bin-oriented heuristic for the two-dimensional bin packing problem with guillotine cuts[J]. Computer & Operations Research, 2011, 38(10): 1443-1451. ALI K, FRANCOIS C, EI-GHAZALI T. Tree decomposition based heuristics for the two-dimensional bin packing problem with conflicts[J]. Computers & Operations Research, 2012, 39(1): 54-63. 姚怡. 二维装箱问题的启发式算法研究[D]. 广州: 华南理工大学, 2016