着色缓存器_新的缓存着色器预处理器(实验性)可加快构建速度

Unity 2020.1 beta引入了缓存着色器预处理器,该预处理器可提高着色器编译速度,最高提升25%,同时遵循C标准并提供新功能,如条件编译选择和预处理源查看。此新特性在大型项目中尤其有用,因为它能有效缓存中间预处理数据,减少编译时间和对包含文件的解析。
摘要由CSDN通过智能技术生成

着色缓存器

Shader compilation is a lengthy process that involves several steps. One of the first steps is preprocessing the shader source. Unity 2020.1 beta introduces the Caching Shader Preprocessor, a new custom solution to perform this compilation step. It is up to 25% faster than the platform compilers’ preprocessor, closely follows the C standard, and offers new features.

着色器编译是一个漫长的过程,涉及多个步骤。 第一步之一是预处理着色器源。 Unity 2020.1 beta 引入了缓存着色器预处理器,这是一种新的自定义解决方案,可以执行此编译步骤。 它比平台编译器的预处理器快25%,紧密遵循C标准并提供新功能。

Anyone who uses Unity deals with shaders, directly or indirectly. Shaders are programs that run on the GPU. They determine how objects are rendered to the screen. When, for example, a point light is added to a scene, objects that need to react to it will use a different shader variant, which defines how to handle point lights.

使用Unity的任何人都直接或间接处理着色器。 着色器是在GPU上运行的程序。 它们确定如何将对象渲染到屏幕上。 例如,当将点光源添加到场景时,需要对其进行React的对象将使用不同的着色器变体,该变体定义了如何处理点光源。

Whenever a new shader variant is used that has not yet been encountered, the Unity Editor has to compile it. When building the application to run on your target device, the Editor needs to compile all of the required shaders.

每当使用尚未遇到的新着色器变体时,Unity编辑器都必须对其进行编译。 在构建要在目标设备上运行的应用程序时,编辑器需要编译所有必需的着色器。

A checkbox to switch the Caching Shader Preprocessor on or off can be found in Editor settings in the Shader Compilation section.

在“着色器编译”部分的“编辑器”设置中,可以找到用于打开或关闭“缓存着色器预处理器”的复选框。

The rest of this blog post covers technical details that you may find useful if you are writing shaders.

本博客文章的其余部分介绍了技术细节,如果您正在编写着色器,这些技术细节可能会有用。

专为速度而打造 (Built for speed)

The new preprocessor caches intermediate preprocessing data to speed up shader import and compilation time. With this caching, the Editor doesn’t need to parse include files until their contents change, and compiling multiple variants of the same shader is more efficient. Enabling the new preprocessor has the most noticeable effect when shaders within a project use a large set of common include files.

新的预处理器缓存中间预处理数据,以加快着色器的导入和编译时间。 通过这种缓存,编辑器不需要解析包含文件,直到它们的内容更改为止,并​​且编译同一着色器的多个变体更加有效。 当项目中的着色器使用大量公共包含文件时,启用新的预处理器具有最明显的效果。

统一性 (Unification)

Different shader compiler back ends come with their own preprocessors. Running a custom standardized preprocessing layer before the compiler is executed ensures that shader code is compatible with any compiler back end used currently or in the future, which in turn means easier project upgrades between Unity versions.

不同的着色器编译器后端带有自己的预处理器。 在执行编译器之前运行定制的标准化预处理层,以确保着色器代码与当前或将来使用的任何编译器后端兼容,这反过来又意味着在Unity版本之间进行更轻松的项目升级。

The same preprocessor is now used during shader importing, replacing the plain text parsing solution employed previously for checking shader compilation parameters (

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值