问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

CesiumJS 技术博客:glTF 模型(Model)加载新架构

发布网友 发布时间:2024-05-11 17:49

我来回答

1个回答

热心网友 时间:2024-05-11 20:52

CesiumJS and glTF's Collaboration: A Journey from 1.0 to 2.0

In 2012, the partnership between CesiumJS and glTF began, marking the foundation for a powerful evolution. The glTF format advanced to version 2.0, seamlessly integrating support for 3DTiles attributes and texture sharing. The CesiumJS team embarked on a mission to revamp their model loading mechanism, with a focus on decoupling load and render, enabling per-vertex data and customizable shaders. This new Model class, born out of necessity, separates loading and parsing, with GltfLoader acting as the intermediary to load glTF files and generate ModelComponents. To optimize memory usage and performance, resources are shared globally through the ResourceCache, significantly recing memory footprint. For instance, the San Diego 3DTiles data set witnessed a remarkable decrease from 564MB to 344MB.


Shader Generation Strategies

"Super Shader" Approach:A single, comprehensive shader file tailored to known algorithms, such as PBR rendering in glTF. This method, exemplified in the code, handles basic diffuse color and occlusion factors.
Dynamically Generated Shaders:Adaptable to unpredictable factors like skinned models with variable joint count, yet requiring careful management to ensure maintainability. processPbrMaterials.js showcases the older implementation.

The new architecture promotes a molar "pipeline stage" design, each stage functioning as a standalone GLSL function, with macro-controlled customization. This molar structure, seen in ModelFS.glsl's main function, mirrors the optimization of "super shaders" while maintaining a fixed pipeline order.


Molar Shader Design in Action

CesiumJS shaders utilize a molar approach, embracing both pre-built "super shaders" and dynamically generated JavaScript. Each material stage follows a standardized format like MaterialStageFS.glsl. Additional stages, such as feature ID handling, generate GLSL code dynamically based on model attributes. This design caters to user requirements, offering expandability and a clear separation between GLSL code and JavaScript logic, stored in dedicated shaders files.


The rendering process involves JavaScript-defined pipeline stages, like XXXPipelineStage, which handle input/output resources like ShaderBuilder, VertexAttributes, uniform maps, and WebGL state variables. By defining GLSL functions in vertex, fragment, or both shaders, developers create DrawCommands that feed CesiumJS's rendering engine. The process encompasses configuring the pipeline, creating resources, executing, and generating ModelDrawCommands, ultimately pushing them into the frameState.


Illustrating the Pipeline: From Simple to Complex

Simple models might have just a few stages, focusing on VertexAttributes, shader transformations, and Material and LightingPipelineStage operations for texture and lighting. More intricate models, such as those utilizing the EXT_mesh_features extension, involve vertex classification and custom visualization through CustomShader.


Custom shaders shine in the MaterialPipelineStage, dynamically generating fragment shaders based on FeatureIds, while CustomShaderPipelineStage allows developers to manipulate materials through a custom fragmentMain() function. The lighting pipeline remains constant.


Integrating glTF and 3DTiles

b3dm and i3dm tiles wrap glTF, incorporating batch and instance transformation tables. Cesium3DTileContent classes cater to each format, with point cloud (pnts) handling independent of glTF. 3DTiles 1.1 supports direct glTF references, enhancing the glTF ecosystem within CesiumJS.


The transition to the Model object in 3DTiles 1.0 marked a simplification, reflecting the introction of the new architecture. My personal journey involved translating and understanding the integration of 3DTiles 1.1 and CesiumJS 2022, along with a deep dive into glTF. This collaboration has propelled the glTF standard forward, particularly with glTF 2.0. The Model architecture unlocks new possibilities, fostering flexibility for future enhancements. Fellow developers have already leveraged this to enhance PBR effects, but there's still much to explore in the domestic scene.

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
如何分别真金和仿金首饰 怎样区分真金和仿金首饰呢 小学生新年晚会主持人的串词!!(不要太多)急 大大后天就需要了!!!_百度... 周年晚会策划公司 奥格瑞玛传送门大厅在哪 奥格瑞玛传送门大厅怎么走 锻炼颈椎的几个动作 水多久能结冰 冰能在多长时间内形成 请问水低于0度会结冰吗? 如何防止脱发严重 嘴唇上有黑印用蜜蜡和棉线去除了胡须 事业编考试用什么文具 马诗古诗 马诗古诗的原文和翻译 最强蜗牛献祭周活动攻略 最强蜗牛神龙许愿攻略最强蜗牛神龙许愿攻略介绍 宏大的什么填空 一个词语后面有宏大两个字是什么 看拼音写词语shi4声yi2声 shi第四声( )泪 描写春天的蓝天的句子有哪些 功能性沙发为什么不能靠墙 晋城市科通创新创业产业园区属于哪个区 山西科通计算机有限公司怎么样 金榜造句 黄榜造句用黄榜造句 古文,求解答 求几个词的古今义区别! 豁然开朗 交通 绝境 就这仨! 润滑油温越高,液位越高吗为什么 利辛到朱集正常运行了吗? 利辛县中学校寒假放假时间 《杨绛传》里的金句朴实无华句句值得细品 如果你死了,世界会不会消失? 晚上开着空调睡觉 早上起来一看玻璃推拉门碎掉了 也没有听到什么声音... 布氏杆菌病+停工留薪期 ...现在只能安装到二十度,请问发电量会有多大影响? 太阳能光伏发电构架仰角150千瓦发电量 描写理想社会的文章诗词。 桃花源记和大道之行也都构建人们心目中的理想社会.从全文看,结合原文分 ... 钩针字母代表什么意思? 四川大竹县违章建筑举报电话 推荐剧搞笑的短篇相声。 纯古代言情小说推荐 桃子emjio是什么意思? 关于春节小学生古诗 思绪回转是回忆从前的意思吗 最近总是有回到以前的感觉,为什么? 鹦鹉能吃什么葡萄糖 油锯链条调好了手能轻松拉动对吗 链锯停了再拉为什么不转了呢? 这油锯上的链条里外怎么这么难弄对啊?有什么方法和技巧吗?急 景泰县开车走兰州西站怎么走近