Low-level native plug-in rendering extensions
Custom packages

Low-level native plug-in Shader compiler access

On top of the low-level native plug-in interface, Unity also supports low level access to the shader compiler, allowing the user to inject different variants into a shader. It is also an event driven approach in which the plug-in will receive callbacks when certain builtin events happen.

Unity 公开的着色器编译器访问扩展定义位于 IUnityShaderCompilerAccess.h 中,随 Editor 提供。

目前仅在 D3D11 上支持这些扩展。随后将有更多平台支持这些扩展。

着色器编译器访问扩展 API

In order to take advantage of the rendering extension, a plug-in should export UnityShaderCompilerExtEvent. There is a lot of documentation provided inside the include file.

A plug-in will get called via UnityShaderCompilerExtEvent whenever one of the builtin events is triggered by Unity. The callbacks can also be added to CommandBuffers via CommandBuffer.IssuePluginEventAndData or CommandBuffer.IssuePluginCustomBlit command from scripts.

In addition to the basic script interface, Native Code plug-ins in Unity can receive callbacks when certain events happen. This is mostly used to implement low-level rendering in your plug-in and enable it to work with Unity’s multithreaded rendering.

定义 Unity 所公开的接口的头文件随 Editor 一起提供。

着色器编译器访问配置接口

Unity provides an interface (IUnityShaderCompilerExtPluginConfigure) to which the shader compiler access is configured. This interface is used by the plug-in to reserve its own keyword(s) and configure shader program and gpu program compiler masks ( For what types for shader or GPU programs the plug-in should be invoked )


Low-level native plug-in rendering extensions
Custom packages