位置: 编程技术 - 正文

Unity3D - 图形性能优化:优化着色器加载时间(unity3d效果图)

编辑:rootadmin
Unity官方文档之“图形性能优化-优化着色器加载时间”的翻译,E文链接。Optimizing Shader Load Time 优化着色器加载时间

推荐整理分享Unity3D - 图形性能优化:优化着色器加载时间(unity3d效果图),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:unity3d图形学,unity地形图片,unity 形变,unity图形化编程,unity 形变,unity自带的图形系统,unity3d图形学,unity3d图形学,内容如对您有帮助,希望把文章链接给更多的朋友!

Shaders are small programs that execute on the GPU, and loading them can take some time. Each individual GPU program typically does not take much time to load, but shaders often have a lot of “variants” internally.

着色器是在GPU上执行的小程序,加载它们需要一些时间。每个独立的GPU程序一般不需要多少时间加载,但是着色器常常有很多内在的“变体”。

For example, the Standard shader, if fully compiled, ends up being many thousands of slightly different GPU programs. This creates two potential problems:

比如,标准着色器如果完全编译,会生成几千个不同的小GPU程序。这会造成两个潜在的问题:

Large numbers of these shader variants increase game build time, and game data size.Loading large numbers of shader variants during game is slow and takes up memory.这些着色器的大量变体会增加游戏打包时间,使游戏包变大。在游戏中加载大量的着色器变体很慢,并且消耗内存。Shader build time stripping 着色器生成时去除

While building the game, Unity can detect that some of the internal shader variants are not used by the game, and skip them from build data. Build-time stripping is done for:

生成游戏包时,Unity可以检测到某些内在着色器变体没有被使用,然后忽略它们。生成时去除可用于:

Individual shader features, for shaders that use #pragma shader_feature. If none of the used materials use a particular variant, then it is not included into the build. Seeinternal shader variants documentation. Out of built-in shaders, the Standard shader uses this.Shader variants to handle Fog and Lightmapping modes not used by any of the scenes are not included into the game data. See Graphics Settings if you want to override this behavior.个别着色器特性,使用#pragma着色器特性的着色器。如果一个变体没有被任何用到的材质使用,那么生成时就不把它打进去。参考内在着色器文档,内置着色器中的标准着色器使用这种方式。没被任何场景使用的处理雾和光照贴图模式的着色器变体,也不会打包到游戏数据中。如果你想改变这个行为,请参考文档图形设置。

Combination of the above often substantially cuts down on shader data size. For example, a fully compiled Standard shader would take several hundred megabytes, but in typical projects it often ends up taking just a couple megabytes (and is often compressed further by the application packaging process).

以上方式的结合可以大大减少着色器数据的大小。比如,完全编译的标准着色器有几百兆,但是在一般的工程中常常只有几兆(而且app打包时会被进一步压缩)。

Default Unity shader loading behavior 默认Unity着色器加载行为

Under all default settings, Unity loads the shaderlab Shader object into memory, but does not create the internal shader variants until they are actually needed.

Unity3D - 图形性能优化:优化着色器加载时间(unity3d效果图)

默认设置下,Unity加载shaderlab着色器对象到内存中,但是内部着色器变体直到被真正用到的时候才创建。

This means that shader variants that are included into the game build can still potentially be used, but there’s no memory or load time cost paid until they are needed. For example, shaders always include a variant to handle point lights with shadows, but if you never end up using a point light with shadows in your game, then there’s no point in loading this particular variant.

这意味着打进游戏包中的着色器变体潜在的可能被用到,但是在用到之前没有占用内存或者消耗时间加载。比如,着色器常常包含一个处理点光源阴影的变体,但是如果你的游戏里从来没有用到点光源阴影,那么加载这个变体就没必要。

One downside of this default behavior, however, is a possible hiccup for when some shader variant is needed for the first time - since a new GPU program code has to be loaded into the graphics driver. This is often undesirable during gameplay, so Unity has ShaderVariantCollection assets to help solve that.

然而,这种默认行为的一个弊端是一些着色器变体第一次被用到的时候可能会出现卡顿(hiccup)——因为需要加载一个新的GPU程序代码到图形驱动。在游戏中这是不能接受的,所以Unity有一个叫ShaderVariantCollection的资源来帮助解决这个问题。

Shader Variant Collections 着色器变体群

ShaderVariantCollection is an asset that is basically a list of Shaders, and for each of them, a list of Pass types and shader keyword combinations to load.

ShaderVariantCollection基本上是一个着色器列表资源,每次加载一个由通道类型和着色器关键字组合的列表。

Shader variant collection inspector 着色器变体群检视器

To help with creating these assets based on actually used shaders and their variants, the editor can track which shaders and their variants are actually used. In Graphics Settings, there is a button to create a new ShaderVariantCollection out of currently tracked shaders, or to clear the currently tracked shader list.

为了帮助创建这些基于被真正用到的着色器和它们变体的资源,编辑器可以追踪哪些着色器和它们的变体被真正用到了。当前追踪着色器的图形设置检视器上,有一个按钮可以创建一个新的ShaderVariantCollection,也可以清除当前追踪的着色器列表。

Creating ShaderVariantCollection from shaders used by editor 从编辑器使用的着色器创建ShaderVariantCollection

Once you have some ShaderVariantCollection assets, you can set for these variants to be automatically preloaded while loading the game (under Preloaded Shaders list in Graphics Settings), or you can preload an individual shader variant collection from a script. See ShaderVariantCollection scripting class.

一旦有了一些ShaderVariantCollection资源,你可以设置这些着色器变体在加载游戏时自动预加载(在图形设置的预加载着色器列表下),或者你也可以用脚本预加载一个独立的着色器变体。参考ShaderVariantCollection脚本类。

See Also 另外可参考Optimizing Graphics Performance. 中文翻译:Unity3D - 图形性能优化。Graphics Settings. 图形设置。Shaders reference. 着色器参考。

[置顶] 我的新书——《NGUI全面实践教程》 欢迎大家到我们团队的官网上查看此书的详细介绍,下面是链接《NGUI全面实践教程》我们的宗旨是:我们只做最专业的技术传播者!为了让广大程序员

[置顶] (六)Unity5.0新特性------新动画功能 unity5.0中的新动画功能这里是你可以期待的新动画功能快速概述!StateMachineBehaviours状态机行为在Unity5中,你会能够将StateMachineBehaviour脚本添加到您

unity导出IOS资源问题 最近做的项目发步,在Andriod上只有多M,在IOS安装包多M,安装后发现IOS的包变成了多M,百思不得其解,被此问题困扰了很久,在网上查了好久,原

标签: unity3d效果图

本文链接地址:https://www.jiuchutong.com/biancheng/383528.html 转载请保留说明!

上一篇:【Unity3D基础教程】给初学者看的Unity教程(一):GameObject,Compoent,Time,Input,Physics(unity3d初学者教程视频)

下一篇:[置顶] 我的新书——《NGUI全面实践教程》(我置顶你也只顶你)

  • 总分公司报税有哪些注意事项
  • 公司账户短期理财收益要交税吗
  • 普票不能抵扣要坐在帐里吗
  • 回购股票不注销没有意义
  • 一般纳税人如何注销
  • 开票资料需要哪些内容
  • 专利年费是不是只能一项一项交
  • 个人独资企业转个体户怎么办理
  • 个人股权转让需要注意什么
  • 企业所得税工资薪金支出怎么填
  • 购买债券取得的利息收入计入什么科目
  • 福利进项税额转出怎么做账务处理
  • 房产税税率和应纳税额
  • 收到认证费用计入什么科目
  • 理财赎回本金没赎回利息咋办
  • 国家减免税额怎么入账
  • 材料成本差异率要算发出材料吗
  • 商品和安装能开什么发票
  • 销售旧房增值税销售额怎么算
  • 收到出口退税计入什么
  • 自产自用的产品用于在建工程
  • 购入已提完折旧的固定资产怎么入账
  • 酒店没有营业执照开业员工有责任吗
  • 购买销售商品
  • 深度学习中模型计算量(FLOPs)和参数量(Params)的理解以及四种计算方法总结
  • 增值税一般纳税人认定标准
  • 华沙的教堂
  • php获取地理位置
  • php imagestring
  • PHP用mysql_insert_id()函数获得刚插入数据或当前发布文章的ID
  • face_recognition库采用了什么算法
  • python面向过程与面向对象的区别
  • 厂家给的返点怎么下往来账
  • abs函数python怎么用
  • 织梦相关文章调用
  • react 上下文hooks内容存储到本地
  • 百旺金赋服务费不交会怎么样?
  • sqlserver2005简介
  • 税务怎么认定虚列工资
  • 受托代销商品的代销方式有哪两种
  • 增值税税负率是多少
  • 借递延所得税资产贷递延所得税费用
  • 账面价值与计税基础的区别和联系
  • 核定征收怎么收
  • 应收贷方余额怎么处理
  • 收到项目资本金怎么入账
  • 营业成本利润率行业均值
  • 管理费用冲减其他费用
  • 旅游服务住宿费可以抵扣吗
  • 咨询企业发生的费用计入
  • 利润表期初余额怎么填
  • 货运代理服务开票
  • 买车保险返现是什么意思
  • 代开专票作废税已经交了如何做分录?
  • 其他应收款如何计提坏账准备
  • 出租车票单张限额
  • 公司被私募基金收购有啥影响 裁员
  • mysql建唯一索引
  • linux中git命令
  • linux系统百科
  • fedora32
  • linux查看组的信息
  • centos inode
  • ubuntu下安装windows
  • win10h2版本
  • win7系统监控
  • opengl数据类型
  • oracle创建emp表
  • unity3d性能优化工具
  • bat批处理if命令
  • unity调色插件
  • nodejs cli
  • nodejs dgram
  • jquery实现分页功能
  • googlevoice使用教程
  • 社保申报后多久缴费
  • 国家税务总局发票查询官网
  • 财政部监制的发票
  • 福建省国家税务局通用定额发票
  • 2020年青海国税工资待遇
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设